You are here: irt.org | FAQ | JavaScript | Form | Q1644 [ previous next ]
Try:
<script language="JavaScript"><!-- function validatePasswords(form) { if (form.P1.value != '' && form.P2.value != '' && form.P1.value == form.P2.value) { return true; } else { alert('Passwords do not match'); form.P1.focus(); return false; } } //--></script> <form onSubmit="return validatePasswords(this)"> Enter Password: <input name="P1" type="password" value=""> Verify password: <input name="P2" type="password" value=""> <input type="submit"> </form>