Web to Lead Required Fields Code
Hello,
I am going round in circles as I can't seem to get the required field validation code to work.
I am hoping that someone can see where I am going wrong? The form is submitting and recording inside the CRM Leads correctly, just can't get the validation script to work :(
<form action='https://crm.zoho.com/crm/WebToLeadForm' name=WebToLeads799553000000060012 method='POST' onsubmit="return validateForm()">
<table border=0 cellspacing=0 cellpadding=5 width=290>
<input type='hidden' name='xnQsjsdp' value='YNMU3XzTdphthYo*kRl79w$$$'/>
<input type='hidden' name='zc_gad' id='zc_gad' value=''/>
<input type='hidden' name='xmIwtLD' value='-QOPKj6pgfUB9ulOp4BfTc69MbjrmvJl'/>
<input type='hidden' name='actionType' value='TGVhZHM='/>
<input type='hidden' name='returnURL' value='http://www.mydomainname.com/index.php' />
<br>
<tr>
<td nowrap align='right' width='25%'>First Name * </td>
<td width='75%'><input type='text' maxlength='40' name='First Name'id='fname' /></td>
</tr>
<tr>
<td nowrap align='right' width='25%'>Last Name * </td>
<td width='75%'><input type='text' maxlength='80' name='Last Name' id='lname' /></td>
</tr>
<tr>
<td nowrap align='right' width='25%'>Email * </td>
<td width='75%'><input type='text' maxlength='100' name='Email' id'email' /></td>
</tr>
<tr>
<td nowrap align='right' width='25%'>Phone * </td>
<td width='75%'><input type='text' maxlength='50' name='Phone' id='phone' /></td>
</tr>
<tr>
<td nowrap align='right' width='25%'>Message </td>
<td width='75%'><textarea name='CONTACTCF4' maxlength='1000' width='250' height='250'></textarea></td>
</tr>
<td colspan=2 align=left><input type='submit' name='save' value='Submit' onclick="return validate_form ();" style='width:100px; height:30px; border-radius:6px; margin-left:85px; cursor:pointer;' />
</td>
</table>
<script>
function validateForm()
{
var fieldarray=new Array("fname","lname","email", "phone");
var alertarray=new Array("First Name","Last Name","Email", "Phone");
for(var i=0;i<fieldarray.length;i++)
{
var value=document.getElementsByName(fieldarray[i])[0].value;
if(value=="" || value =="-None-")
{
alert(alertarray[i]+" cannot be empty");return false;
}
}
var thefrm=document.contactForm;
if(thefrm.enterVerify.value=="")
{
alert("Enter your Verification Code");
thefrm.enterVerify.focus();
return false;
}
else if(thefrm.enterVerify.value!="")
{
if(thefrm.enterVerify.value!=thefrm.varifyNumHidden.value)
{
alert("please Enter Currect Verification Number");
randomgen();
thefrm.enterVerify.select();
thefrm.enterVerify.focus();
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
</script>
</form>