View Full Version : password compare

07-06-2006, 08:04 AM
I want the user to enter their password twice to avoid errors. Below is an extract of my current code.
I have now put two inputs for their email address. How do I change my code to check if both are the same please.
<input TYPE="text" NAME="email">
<input TYPE="text" NAME="email2">

if (!validateInputBox(document.theForm.nickname.value))
{ isValid = false; alert(' Please fill in your name.'); }
if (!validateInputBox(document.theForm.vpassword.value))
{ isValid = false; alert(' Please fill in the password of your message.'); }
if (!validateEmail(document.theForm.email.value))
{ isValid = false; alert(' Please fill in a correct email address.'); }

if (isValid)
alert ("Thank you. Your form is being sent.");
return isValid;
function validateInputBox(text) {
return (text.length > 0);
function validateEmail(emailAddress) {
var match = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/.test(emailAddress);
return match;
cheers Peter

Philip M
07-06-2006, 08:51 AM
if ((document.theForm.email.value) != (document.theForm.email2.value))
{ isValid = false; alert('email addresses not the same - please re-enter');
document.theForm.email2.value = "";
document.theForm.email.value = "";

If the two match then you can proceed to test whether the address is syntactically valid.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum