Contact Us Today!

Request CRM InfoDo you need a CRM for marketing automation, customer self-service, call center solutions, or other needs? We will help you find vendors that provide the services you need.

Web-to-Lead Form Validation Print E-mail
Tuesday, 25 September 2007 17:50

Nobody gets excited about dirty data in a CRM implementation.  One great way to keep your data clean is to implement client-side javascript validation with your web-to-lead forms.  This is a valuable technique for ensuring that a user completes certain required fields before they can submit your form.   Just be careful not to overdo it, implementing excessive form validation will annoy users and cause your conversion rates to drop, so consider any client side validation alongside your marketing objectives.

Web_to_lead_form_validation_3

The Web-to-Lead Validation Call

Simply add the following onsubmit function call to your existing Salesforce web-to-lead forms as shown by green text in the example below.  Please note that other javascript functions (such as placing an onclick function on your submit button) are not certified.

       

<form action="https://www.salesforce.com/servlet/servlet.WebToLead" method="POST" onsubmit="return validation(this);">

      

<input type=hidden name="oid" value="insert_your_oid_here">
<input type=hidden name="retURL" value="http://www.company.com/thanks.html">

      

<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

      

<label for="last_name">Last Name</label><input id="last_name" maxlength="40" name="last_name" size="20" type="text" /><br>

      

<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>

      

<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>

      

<input type="submit" name="submit">

      

</form>


The Validation Function
Then include a javascript validation function, either directly in your HTML header or by reference.  For example:

       

function validation(form) {
      
      
if(form.first_name.value == '') {

alert('Please enter your first name');
form.first_name.focus();
return false;
}


if(form.last_name.value == '') {

alert('Please enter your last name');
form.last_name.focus();
return false;
}

if(form.email.value == '') {

alert('Please enter your email address');
form.email.focus();
return false;
}


if(form.company.value == '') {

alert('Please enter your company');
form.company.focus();
return false;
}

return true;
}


Certififed with Salesforce for Google AdWords

The techniques noted here are supported with standard web-to-lead forms and are certified not to conflict with the website tracking provided by Salesforce for Google AdWords.  As always, please contact us with questions via email: sfga (at) salesforce (dot) com