Checking password strength using AJAX

This script will check the password strength.This is implemented by Aj

Page 1 of 1

3 Replies - 6390 Views - Last Post: 16 June 2009 - 08:09 AM

#1 divyasmk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-May 09

Checking password strength using AJAX

Post icon  Posted 16 June 2009 - 04:04 AM

This is my first post......

Password strengthness checking using Ajax and PHP

It contains 3 following files files..

1.password.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="pass.js"> </script> 
<style type="text/css">
<!--
.style1 {
	font-family: "Times New Roman", Times, serif;
	color: #993366;
	font-weight: bold;
	font-size: 24px;
}
.style2 {
	font-family: "Times New Roman", Times, serif;
	font-weight: bold;
	font-size: 18px;
	font-style: italic;
	color: #CC0033;
}
-->
</style>
</head>

<body bgcolor="#99FFFF">
<form id="form1" name="form1" method="get" action="">
  <div align="center">
	<p>&nbsp;</p>
	<p class="style1">Login form</p>
	<p>&nbsp; </p>
	<table width="547" border="0" bgcolor="#99CCFF">
	  <tr>
		<td width="148"><p>&nbsp;</p>
		<p class="style2">User Name </p></td>
		<td width="336"><label> <br />
			<br />
			  <input type="text" name="textfield" />
		</label></td>
	  </tr>
	  <tr>
		<td class="style2">Password</td>
		<td><label>
		  <input type="text" name="t2" id="txt1" onkeyup="showHint(this.value)" />
		 <label style="color:#FF0000" id="txtHint"></label>
		</label></td>
	  </tr>
	  <tr>
		<td colspan="2"><label>
		  <div align="center">
			<p>
			  <input type="submit" name="Submit" value="Submit" />
			</p>
			<p>&nbsp;</p>
			<p>&nbsp;  </p>
		  </div>
		</label></td>
	  </tr>
	</table>
	<label></label>
  </div>
</form>
 <p style="color:#FF0000" id="txtHint"></p> 
</body>
</html>
[u]2.pass.js[/u]

// Javascript Document
var xmlHttp;

function showHint(str)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
var url="getpass.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

[u]3.getpass.php[/u]

<? $q1=$_GET["q"];

//lookup all hints from array if length of q>0
$l=strlen($q1);
if (strlen($q1) <=4  )
{
$response="Password length  is bad";
}
if ((strlen($q1) >4 )&& (strlen($q1) <=6 )   )
{
$response="Password length is good";
}
 if ((strlen($q1) >6 )&& (strlen($q1) <=10 ) ) 
{
$response="Password length is strong";
}
 if ((strlen($q1) >10 ) ) 
{
$response="Password length  is very strong";
}

//output the response
echo "<span style=background-color:#FFFFCC>".$response."<br>Your password contain"."  ".$l."Characters"."</span>";

?>


Is This A Good Question/Topic? 0
  • +

Replies To: Checking password strength using AJAX

#2 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

Re: Checking password strength using AJAX

Posted 16 June 2009 - 05:43 AM

Couple things...

1. The introduce yourself forum is not the correct place for technical questions.
2. What seems to be the problem with your code? You will need to provide us with more information.

:code:


I would like to point you in the direction of our site rules. SITE RULES
Was This Post Helpful? 0
  • +
  • -

#3 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Checking password strength using AJAX

Posted 16 June 2009 - 05:45 AM

...and please post your question in the body, not the description field, please.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Checking password strength using AJAX

Posted 16 June 2009 - 08:09 AM

Moving to Javascript :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1