How to Add Required Fields to salesforce.com Web to Lead Forms
When you generate a Web to Lead Form in salesforce.com, there are no required fields included by Salesforce. This means that if you install the HTML Web to Lead form in your website, you'll get allot of incomplete or blank Leads in your Salesforce Org.
This is a common problem. If you already have a Salesforce Web to Lead form on your website and you haven't added your own field validation, then it's likely that you frequently receive Leads with essential fields such as name, email address or phone number omitted.
One simple solution to this problem is to validate the essential fields in your Salesforce Web to Lead form with a JavaScript field validation script.
INSTRUCTIONS
First add the following call to your new validation function when the form is submitted. You do this by adding a "onsubmit" attribute to your FORM tag, like the following (keep it on one line if possible):
<form action="your-sfdc-action" method="post" onsubmit="return checkform(this);">
Next, add the following validation function to the HEAD portion of your HTML document:
(note that this example code is configured to require first name, last name, email and phone)
<!--- Begin Surfwriter.com Web to Lead Validation Script--->
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( 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.phone.value == "") {
alert( "Please enter your phone number." );
form.phone.focus();
return false ;
}
return true ;
}
//-->
</script>
<!--- End Surfwriter.com Web to Lead Validation Script--->
Have fun,
Surfwriter, Inc.
Learn more: http://surfwriter.com
This is a common problem. If you already have a Salesforce Web to Lead form on your website and you haven't added your own field validation, then it's likely that you frequently receive Leads with essential fields such as name, email address or phone number omitted.
One simple solution to this problem is to validate the essential fields in your Salesforce Web to Lead form with a JavaScript field validation script.
INSTRUCTIONS
First add the following call to your new validation function when the form is submitted. You do this by adding a "onsubmit" attribute to your FORM tag, like the following (keep it on one line if possible):
<form action="your-sfdc-action" method="post" onsubmit="return checkform(this);">
Next, add the following validation function to the HEAD portion of your HTML document:
(note that this example code is configured to require first name, last name, email and phone)
<!--- Begin Surfwriter.com Web to Lead Validation Script--->
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( 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.phone.value == "") {
alert( "Please enter your phone number." );
form.phone.focus();
return false ;
}
return true ;
}
//-->
</script>
<!--- End Surfwriter.com Web to Lead Validation Script--->
Have fun,
Surfwriter, Inc.
Learn more: http://surfwriter.com
Labels: Force.com, Salesforce.com, Web to Lead

<< Home