password checker

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

password checker

Post 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?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: password checker

Post 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?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: password checker

Post 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'.
User avatar
waytoecommerce
Forum Newbie
Posts: 16
Joined: Tue Apr 12, 2011 11:47 am

Re: password checker

Post 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!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: password checker

Post 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).
Post Reply