Connecting Tech Pros Worldwide Help | Site Map

password validation

brijesh
Guest
 
Posts: n/a
#1: Jul 20 '05
i am relatively new to javascript
i am trying for a password validation code
but iam not able to stop the page from loading the page when the
password is wrong. the code is as below
------------------
<html>
<head>
<title>New User</title>
<script language = "JavaScript">
function validatePasswords() {
if (document.passForm.password1.value !=
document.passForm.password2.value) {
alert("Passwords don't match, try again");
document.passForm.password1.focus();
document.passForm.password1.select();
return false;
} else
return true;
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="passForm" method="post" onsubmit="validatePasswords()"
action="http://www.google.com">
<h1>New user password form</h1>
<p> Username: <input type="text" name="username"><br>
Password: <input type="password" name="password1"><br>
Check password: <input type="password" name="password2"><br>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

</body>
</html>
-------------------
can u please tell me where am i going wrong
thank you
waiting eagerly for some suggestions
Brijesh
kaeli
Guest
 
Posts: n/a
#2: Jul 20 '05

re: password validation


In article <7bccde45.0311130230.2ecccc21@posting.google.com >,
brijesh@divinetaccess.com enlightened us with...[color=blue]
> i am relatively new to javascript
> i am trying for a password validation code
> but iam not able to stop the page from loading the page when the
> password is wrong. the code is as below
>
> <body bgcolor="#FFFFFF" text="#000000">
> <form name="passForm" method="post" onsubmit="validatePasswords()"[/color]

You forgot the return.
onsubmit="return validatePasswords()"



--
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Closed Thread