Forum Moderators: open
I need to set it up to verify the email address is the same in two different fields on a regular HTML form mail.
For example, there is email field one, then email field two. They should enter the same email in both to verify they have typed it correctly.
Does anyone have a script for this?
I have searched here and on Google and all I can find is an email verification script such as the following, but not one which verifies that the two fields have been filled out the same.
<script language=javascript>
<!--
function openwindow(test) {
window.open(test, 'test', 'toolbar=no,scrollbars=2,location=no,status=no,menubar=no,resizable');
}
function validate(form)
{
//Data validation using object names to reference objects
if (form.contactname.value == "")
{
alert("You must enter your name!");
form.contactname.focus()
return false;
}
if (form.contact2.value == "")
{
alert("You must enter your email!");
form.contact2.focus()
return false;
}
}
// -->
</script>
I am lousy with javascript. I can cut and paste it, but my right brain simply refuses to understand it ;) So any help is greatly appreciated!
I tried that, but it didn't work. I think it might have to do with not naming the Email1 and Email2 fields correctly, but because they are being compared I am not sure exactly how to do it.
Below is both my script and my form.
<SCRIPT LANGUAGE = "JavaScript">
<!--
function replaceme(which,img) {
which.src = img;
}
function restoreme(which,img) {
which.src = img;
} >
function validate(form)
{
//Data validation using object names to reference objects
if (form.contactname.value == "")
{
alert("You must enter your name!");
form.contactname.focus()
return false;
}
if(Email1!= Email2) {
alert("Not the same");
}
}
// -->
</SCRIPT>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form METHOD="POST" ACTION="http://www.mysite.com/cgi-bin/form.pl">
<input type="hidden" name="subject" value="Visitor Inquiry">
<input type="hidden" name="redirect" value="http://www.mysite.com/thankyou.htm">
<input type="hidden" name="recipient" value="inquiry@mysite.com"><div align="center">
<center>
<table width="100%" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td align="right" width="376" colspan="2">
<p align="left"><img border="0" src="images/divider.gif" width="1" height="1"></p>
</td>
</tr>
</center>
<tr>
<td align="right" width="376" colspan="2">
<p align="left"><b>Contact Us</b>
</td>
</tr>
<tr>
<td align="right" width="154">
<p align="left"><b>Your Name</b>
</td>
<center>
<td width="222">
<b>
<input maxLength="40" name="contactname" size="39" style="font-size: 10px; color: #6D6D36; font-family: Arial; border: 1 solid #6D6D36">
</b>
</td>
</tr>
<tr>
<td align="right" width="154">
<p align="left"><b>Email Address</b></p>
</td>
<b>
<td width="222"><input maxLength="40" name="Email1" size="39" style="font-size: 10px; color: #6D6D36; font-family: Arial; border: 1 solid #6D6D36"></td>
</b>
</tr>
<tr>
<td align="right" width="154">
<p align="left"><b>Verify Email</b></p>
</td>
<b>
<td width="222"><b><input maxLength="40" name="Email2" size="39" style="font-size: 10px; color: #6D6D36; font-family: Arial; border: 1 solid #6D6D36"></b></td>
</b>
</tr>
</center><b>
<center>
</center>
<tr>
<td align="right" width="406" colspan="2">
<img border="0" src="images/divider.gif" width="1" height="1"></td>
</tr>
<tr>
<td align="right" width="153">
<p align="left"></td>
<center>
<td align="left" width="253"><b><input type="submit" value="Submit Request" style="font-size: 10px; font-family: Arial; color: #6D6D36; font-weight: bold"></b></td>
</tr>
</center>
</b>
</tbody>
</table>
</div>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>