Greetings – I am new to WordPress. I created a short registration form that submits to an email address (I am using Go Daddy hosting and their email script webformmailer.php). The form submits properly, but I can’t get the Javascript validation to work. Below is the code. Any troubleshooting help is much appreciated. Thanks in advance.
This is the file validate.js – I uploaded it to the root directory of my hosting account.
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.form.MemberFirstName.value=="") {
themessage = themessage + " - First Name";
}
if (document.form.MemberLastName.value=="") {
themessage = themessage + " - Last Name";
}
if (document.form.Email.value=="") {
themessage = themessage + " - E-mail";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
This is the html file on the web site.
<script type="text/javascript" scr="/validate.js"></script>
<script type="text/javascript">
<!--verify();
//--></script>
<form action="/webformmailer.php" enctype="application/x-www-form-urlencoded" method="post" >
First Name: <input name="MemberFirstName" size="40" type="text" />
Last Name: <input name="MemberLastName" size="40" type="text" />
Email Address: <input name="Email" size="50" type="text" />
<input name="submit" type="submit" value="Submit Contest Entry" onclick="verify();"/>
</form>