Click to See Complete Forum and Search --> : password validation


maddirala
08-03-2004, 07:08 PM
Hi

I need to validaemy passwoed.it should be 8 characters and must not contain part(letters in username) of user name.
can anyone giveme idea or code.

i have tried foloowing this

<script language="JavaScript">

function goAdd(form1){
if(form1.userName.value == null || form1.userName.value.length <8 ){
alert('Please fill in the User Name.');
form1.userName.focus();
return false;
}
if(form1.password.value == null || form1.password.value.length == 0){
alert('Please fill in the Password.');
form1.password.focus();
return false;
}

for(i = 0 ; i < form1.userName.value.length ; i++){
var str = form1.userName.value.substring(i , form1.userName.value.length);
alert(str);
if (form1.userName.value.indexOf(form1.password.value) == -1) {
if (str.indexOf(form1.password.value) == -1) {
alert('Valid Password');
return true;
}else{
alert('Incorrect Password.');
return false;
}
} }
}
</script>

thanks for anyhelp

Charles
08-03-2004, 07:30 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>
</head>
<body>
<form action="someScript.pl">
<fieldset>
<legend>Log in</legend>
<label>User Name<input id="user" type="text"></label>

<label>Password<input type="password" onchange="if (this.value.length != 8 || new RegExp (this.form.user.value, 'i').test(this.value)) {alert('That would not appear to be a valid password.'); this.value = ''; this.focus()}"></label>

<button type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>

sciguyryan
08-04-2004, 03:28 AM
Or, you cna look here:

http://www.regexplib.com