Can anyone tell me what I am doing wrong? my comparePasswords() is not working…
<script>
function comparePasswords()
{
if (post-form.password.value != post-form.password2.value)
{
$('passwordShow').innerHTML = '';
}
else
{
$('passwordShow').innerHTML = 'Passwords do not match';
}
}
</script>
<form id="post-form" action="signup.php" method="post" >
<input type="password" id="password" name="password" onkeyup="testPassword(this.value);" maxlength="50" size="25" tabindex="102" value="">
<input type="password" id="password2" name="password2" onkeyup="comparePasswords();" maxlength="50" size="25" tabindex="104" value="">
</form>
you need to use
and
Also, your logic is wrong. The first conditional block will fire if the passwords do not match.
EDIT
seems you are using jQuery, so simply use
to get the field’s value.
You should also set the innerHTML using jQuery (may as well) with the
html()method