Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1644 How do you have a user enter a password, then re-enter the password to be verified?

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>

©2018 Martin Webb