This is my first post......
Password strengthness checking using Ajax and PHPIt contains 3 following files files..
1.password.htmlCODE
<!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> </p>
<p class="style1">Login form</p>
<p> </p>
<table width="547" border="0" bgcolor="#99CCFF">
<tr>
<td width="148"><p> </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> </p>
<p> </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>";
?>