Page 1 of 1

password checker

Posted: Tue Apr 12, 2011 7:24 pm
by Vegan
OK i have this page I am developing on security and I am adding a password checker

Code: Select all

<div class="centered">
<form method="post"><input name="text1" style="width: 400px" type="text">&nbsp;&nbsp;&nbsp;<input name="Button1" type="button" value="Check It"></form>
<p>The approximate entropy of the password is: </p>
</div>
So I was wondering, I need to check the text1 value to see what it contains, digits, letters symbols and length

can javascript manage with regular expression type constructs?

Re: password checker

Posted: Tue Apr 12, 2011 8:39 pm
by Vegan
Well a bit of progress. Have the text box and a onclick to a script to deal with the text box

so looking at regular expressions

do I need to use hard coded crap like [0123456789] and so on to detect certain classes of password?

Re: password checker

Posted: Tue Apr 12, 2011 10:25 pm
by califdon
It all depends on just what you want to do. Yes, Javascript supports a pretty standard regex matching syntax. Look up 'javascript regex match'.

Re: password checker

Posted: Wed Apr 13, 2011 1:10 am
by waytoecommerce
<!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 language="Javascript">
function alphaNumericCheck(){
var regex=/^[0-9A-Za-z]+$/; //^[a-zA-z]+$/
if(regex.test(document.checkform.password.value)){
alert("Good")
return true;
} else {
alert("Please fix: password")
return false;
}
}
</script> </head>

<body>
<div class="centered">
<form name="checkform" method="post" onsubmit="javascript: check();"><input id="password" name="text1" style="width: 400px" type="text">&nbsp;&nbsp;&nbsp;<input name="Button1" type="button" value="Check It"></form>
<p>The approximate entropy of the password is: </p>
</div>
</body>
</html>


thanks!

Re: password checker

Posted: Wed Apr 13, 2011 12:06 pm
by califdon
waytoecommerce: When posting code in the forum, please use the appropriate [syntax] tags to enclose the code to make it readable. You can simply use the button "PHP Code" at the top of the place where you are entering your post (if it's not PHP code, you can just change it, for example, to

Code: Select all

 or whatever).