School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,422 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,523 people online right now. Registration is fast and FREE... Join Now!




Checking password strength using AJAX

 

Checking password strength using AJAX, This script will check the password strength.This is implemented by Aj

divyasmk

16 Jun, 2009 - 03:04 AM
Post #1

New D.I.C Head
*

Joined: 7 May, 2009
Posts: 2

This is my first post......

Password strengthness checking using Ajax and PHP

It contains 3 following files files..

1.password.html
CODE

<!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>";

?>





User is offlineProfile CardPM
+Quote Post


jjsaw5

RE: Checking Password Strength Using AJAX

16 Jun, 2009 - 04:43 AM
Post #2

I must break you
Group Icon

Joined: 4 Jan, 2008
Posts: 2,656



Thanked: 25 times
Dream Kudos: 125
My Contributions
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.gif


I would like to point you in the direction of our site rules. SITE RULES
User is offlineProfile CardPM
+Quote Post

firebolt

RE: Checking Password Strength Using AJAX

16 Jun, 2009 - 04:45 AM
Post #3

D.I.C Lover
Group Icon

Joined: 20 Feb, 2009
Posts: 5,463



Thanked: 75 times
Dream Kudos: 1675
My Contributions
...and please post your question in the body, not the description field, please.
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Checking Password Strength Using AJAX

16 Jun, 2009 - 07:09 AM
Post #4

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Moving to JavaScript smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 12:12AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month