...

View Full Version : Can Any Coders figure this out



emd2kick
05-23-2009, 02:51 AM
Hey All,
I'm so deep into this I don't know what I'm doing anymore. I'm trying to use script to confirm an email address. Anyone can correct this code for me?
Thanks for you help guys!!!



<form id="frmSurvey" name="frmSurvey" onsubmit="javascript: return false; " action="CaptureFrontDatasheetDecide.jsp" method="post"><!-- Begin: Global Form Tags -->

<input type="hidden" value="" name="userAgent">
<input type="hidden" value="y" name="updateFlag">
<input type="hidden" value="n" name="ansQues1IsNo"> <!-- END: Global Form Tags -->

<table style="WIDTH: 200px" cellspacing="1" cellpadding="0" border="1">
<tbody>
<tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">First Name: </span>
<input type="text" value="($custom2)" name="firstName" AUTOCOMPLETE="OFF">&nbsp;</td>
</tr>
<tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Last Name: </span>
<input type="text" value="($custom3)" name="lastName" AUTOCOMPLETE="OFF">&nbsp;</td>
</tr>
<tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Title: </span>
<input type="text" value="($custom4)" name="title" AUTOCOMPLETE="OFF">&nbsp; </td>
</tr>
<tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Company: </span>
<input type="text" value="($custom5)" name="company" AUTOCOMPLETE="OFF"></td>
</tr>
<tr><td valign="top" align="left"><p>Enter E-Mail Address: -
<input id="emailadd" onblur="javascript: checkValidEmail() " type="text" size="42" value="($prospectEmail)" name="email" AUTOCOMPLETE="OFF" input="">
</p></td>
</tr>
<tr><td valign="top" align="left"><p>Confirm Email Address: -
<input id="conemail" onblur="javascript: checkConfirmEmail() " type="text" size="42" value="($custom1)" name="custom1" AUTOCOMPLETE="OFF" input="">
</p></td>
</tr>
<tr><td valign="top" align="left"></td>
</tr>
<tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Address 1: </span>
<input type="text" value="($custom6)" name="address1" AUTOCOMPLETE="OFF">&nbsp;
</p></td>
</tr>
<tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Address 2: </span>
<input type="text" value="($custom7)" name="address2" AUTOCOMPLETE="OFF">&nbsp;
</p></td>
</tr>
<tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">City: </span>
<input type="text" value="($custom8)" name="city" AUTOCOMPLETE="OFF">&nbsp;
</p></td>
</tr>
<tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">State: </span>
<input type="text" value="($custom9)" name="state" AUTOCOMPLETE="OFF">&nbsp;
</p></td>
</tr>
<tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Zip: </span>
<input type="text" value="($custom10)" name="zip" AUTOCOMPLETE="OFF">&nbsp;
</p></td>
</tr>
<tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Daytime Phone: </span>
<input type="text" value="($custom11)" name="phone" AUTOCOMPLETE="OFF">&nbsp;
</p></td>
</tr>
<tr><td valign="top" align="left"><input onclick="javascript: doSubmit();return false; " type="button" value="Submit" name=""> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</form>
<script type="text/javascript">
function checkValidEmail() {
email1= document.myform.emailadd.value;
if (/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@(([\w\-]?)+\.)+([a-z]{2,4})$/i.test(email1)) {
}
else {
alert ("Invalid Email Address - Please Re-Enter");
document.myform.emailadd.value = "";
document.myform.emailadd.focus();
}
}
function checkConfirmEmail() {
email2 = document.myform.conemail.value;
if (email2 != email1) {
alert ("Email addresses do not match - please re-enter!");
document.myform.emailadd.value = "";
document.myform.conemail.value = "";
document.myform.emailadd.focus();
}
else {
}
}
</script>

abduraooft
05-23-2009, 08:24 AM
Get a copy of firebug (http://getfirebug.com) for your FF, which may help you to track the errors by yourself.

PS: Use an input element having type="submit", for submitting your form, otherwise your form will do nothing in the absence of javascript support. You may need to call your validation procedure from the onsubmit attribute of your <form>

Philip M
05-23-2009, 05:59 PM
email1= document.myform.emailadd.value;

but your form is named "frmSurvey" not "myform"
and the element name is "email" (athough you have an id of "emailadd")

Put these right - i.e. make them consistent, and it will work.


"To get back my youth I would do anything in the world, except take exercise, get up early, or be respectable." - Oscar Wilde (Irish Poet, Novelist, Dramatist and Critic, 1854-1900)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum