View Full Version : Checking if passwords match on registration.

11 Jul 2010, 11:48 PM
So, for a simple little example of what I want to do...


Desired Username: <input type="text" name="username">
Password: <input type="text" name="password">
Verify pass: <input type="text" name="passwordcheck">


I want to rig up something that will automatically check the values posted in "password" and "passwordcheck" before the form is submitted making sure that they match each other and give a little error message if they don't. Ideally, if they don't match it would also prevent the form from even being submitted. My knowledge of Javascript is pretty basic, in fact it primarily consists of what's covered under the "basic" category in w3schools.com's Javascript tutorial, as well as a very modest understanding of form validation in the "advanced" section of the same site. So I haven't had much luck trying to accomplish this myself.

Can anyone offer any help? I don't need anything especially fancy (since if it were it would likely be beyond my comprehension at the moment) I just need it to be functional.

12 Jul 2010, 05:37 AM
On the form tag, add the following:

onsubmit="check_passwords( this );"

in the head section have:

function check_password( vtarget ){

if( vtarget.password.value != vtarget.passwordcheck.value )
return false;
return true;


I think thats it.