...

View Full Version : Trying to create a simple password verification



MaDmiX
07-16-2012, 04:25 PM
Hi All,

I am trying to create a script that will compare two text fields on my form and submit the form if the fields match or give an alert if they don't. It's for a password verification. For some reason the fields are not returning any value. I tried setting alerts for each text field variable and got back the following:

[Object HTMLInputElement]

I tried adding innerHTML when setting the variables but that returns nothing (an empty string or null). It seems like this should work... It's sooo simple but I don't know why it's not. If anyone can pinpoint what I am doing wrong I would be grateful:


<script type="text/javascript">
function verifyPass() {
var pass=document.getElementById("password");
var vpass=document.getElementById("verifyPassword");
if (pass==vpass) {
// alert(pass);
// alert(vpass);
// alert("the form should be submitted");
document.getElementById("frmAddUser").submit();
}else{
// alert(pass);
// alert(vpass);
alert("The passwords do not match.");
}
}
</script>

DrDOS
07-16-2012, 04:36 PM
You forgot to add the word value. That's all.

("verifyPassword").value

MaDmiX
07-16-2012, 04:45 PM
You forgot to add the word value. That's all.

("verifyPassword").value

Doh!!! I am embarassed :-)
Working now. Many thanks.

Ken

Philip M
07-16-2012, 04:51 PM
alert("The passwords do not match.");
return false;
}

If you omit return false the form will submit regardless. And you must call your function with return verifyPass()

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum