Confirm Email Address in Form (URGENT)

G

Guest

I want people to re-type their email address to confirm their email address
in a form I have. However, if they accidentally type a different address in,
they are not prompted of the error on "submit". How do I validate or set the
field properties to require the same address in the field as in the original
email field on "submit"?
 
M

MD Websunlimited

Hi Michelle,

You compare the two fields.

<input type="submit" onclick="if (this.field1.value == this.field2.value) { return true; } else { alert('Email addresses do not
match!'); this.field1.focus(); return false; } " value="Submit" >

Or, you may wish to look at the J-Bots Form Components -- Compare Two.
 
G

Guest

Hi Mike,

I'm not quite sure I get it. The name of the first field is "email_address"
and the name of the second field is "confirm_email". How do I write the code?
 
G

Guest

I'm not quite sure I get it. Where do I put the name of the field? Do I
replace the text "field1" or "this.field1" or "this.field1.value" with the
field name?
 
A

Andrew Murray

http://javascript.internet.com - this has a "password validation script"
where you enter your password twice; but it's adaptable to whatever you
like, such as email addresses.

This is the one:

<!-- TWO STEPS TO INSTALL PASSWORD VERIFIER:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Carey Walker ([email protected]) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function checkPw(form) {
pw1 = form.pw1.value;
pw2 = form.pw2.value;
full_name=form.full_name.value;

if (pw1 != pw2) {
alert ("\nYou did not enter the same new password twice. Please re-enter
your password.")
return false;
}
else return true;
}
if (full_name = "") {
alert ("\n No value was entered in the NAME field. Please enter a value")
return false;
}
else return true;
}
// End -->
</script>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<form onSubmit="return checkPw(this)">
<center>
<table border=0>
<tr>
<td>Password:</td><td><input type=text name=pw1 size=10></td>
</tr>
<tr>
<td>Re-enter:</td><td><input type=text name=pw2 size=10></td>
</tr>
<tr>
<td colspan=2 align=center><input type=submit value="Submit!"></td>
</tr>
</table>
</form>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.13 KB -->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top