Robert, thank you for the reply and suggestion. My question is still a
very specific one, where the rubber meets the road! Where in my code
do I put the <form> and <script> code that you suggested? Im having
trouble making it work with my exisiting code that posts the form to a
cgi script. Here is the web address if you want to take a look at my
current code. Do I just insert the new code to compare around the
fields I want it to include (the email and confirm email fields). Not
sure if it nests inside the original <form> codes. Thanks for your
help!
http://nurturingnetwork.org/clientquest/clientquesta.html
NB
I noticed that you are working with a charity. That motivated me to
write the folowing example.
If you server application doesn't ignore the second userid field try
inserting this line at the end of checkEmail:
document.forms[0].e_confirmed_email.value = '';
or you can try inserting:
document.forms[0].e_confirmed_email.value = null;
One of these and I think it is the first will prevent the field from
being set to the host.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>clientquesta</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1">
<SCRIPT type="text/javascript">
function diffEmail()
{
// If the person enters two email address, verify that they
// are both the same.
// This doesn't for the person to enter either one or make
// them the same.
if (document.forms[0].e_email.value != ""
&& document.forms[0].e_confirmed_email.value != ""
&& document.forms[0].e_email.value !=
document.forms[0].e_confirmed_email.value)
{
// Put out an alert to suggest the person fix the email address
alert("Your confirmation email address differs from you email"
+ " address. "
+ "Please correct your email address.");
}
}
function checkEmail()
{
var i;
if (document.forms[0].e_email.value !=
document.forms[0].e_confirmed_email.value)
{
// Try getting a matching userid up to three times.
for (i=1;i<4;i++)
{
// Ask the person to try again.
userEmail = window.prompt("Your confirmation email address"
+ " differs from you email"
+ " address."
+ " Please enter your correct email address address.","");
if (document.forms[0].e_email.value == userEmail)
{
document.forms[0].e_confirmed_email.value = userEmail;
break;
}
else if (document.forms[0].e_confirmed_email.value == userEmail)
{
document.forms[0].e_email.value = userEmail;
break;
}
else
{
// We didn't find a match. Change an arbitrary email
// address and ask the user again.
document.forms[0].e_confirmed_email.value = userEmail;
}
}
}
}
</script>
</HEAD>
<BODY>
<br><br><br><br><br><br>
<FORM METHOD="POST" ACTION="http:error"
onSubmit="checkEmail();">
<TABLE ALIGN="center" BORDER=0 CELLSPACING=0 CELLPADDING=0
WIDTH="600">
<TR><TD></TD><TD WIDTH=220><BR>Email address</TD>
<TD COLSPAN=2 WIDTH=370><BR><INPUT
TYPE="text" NAME="e_email" Size=60 onBlur="diffEmail();"></TD></TR>
<TR><TD></TD><TD WIDTH=220><BR>Confirm Email address</TD>
<TD COLSPAN=2 WIDTH=370><BR><INPUT
TYPE="text" NAME="e_confirmed_email" Size=60
onBlur="diffEmail();"></TD></TR>
<TR><TD></TD><TD WIDTH=220><BR>another field</TD>
<TD COLSPAN=2 WIDTH=370><BR><INPUT
TYPE="text" NAME="anotherField" Size=60 ></TD></TR>
</TABLE>
<input type="submit" value="Submit form">
</FORM>
</BODY>
</HTML>