You need to sign in to do that
Don't have an account?
Validation noob question
Hi. Today I was asked to create a lead form that would connect to the lead object. The form itself was easy to set up, and it works fine. However, now I want to add validation to the form.
I have created a basic validation rule for the first name that looked like this:
ISBLANK( FirstName), specified the error position to be Field, activated the validation rule.
At this point I expected for it to kick in if I were to submit a form with empty last name. However, I got redirected to the success page, but the empty lead didn't get registered in the system. Does it mean the validation worked? Or was it some kind of default validation? Are there any mistakes in my workflow?
Any ideas would be very welcome.
Thanks!
Luka
If this is a standard web-to-lead form, you'll have to add javascript validation to get the effect you want.
You'll only see the validation error when entering the lead from within salesforce.
Here's a very basic web-to-lead form with sample javascript validation:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Web-to-Lead Form</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function submitForm(form) { var errorMsg=""; if( document.getElementById('first_name').value === '' ) {
errorMsg += 'First Name is required.\n'; }
//add other fields to validate here... if( errorMsg === '' ) { return true; } else { alert( "Error:\n\n" + errorMsg ); return false; } } </script> </head> <body> <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" onsubmit="return submitForm( this );" method="POST"> <input type=hidden name="oid" value="xxxx0000000xxxx"> <input type=hidden name="retURL" value="http://successpage.html"> <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
All Answers
If this is a standard web-to-lead form, you'll have to add javascript validation to get the effect you want.
You'll only see the validation error when entering the lead from within salesforce.
Here's a very basic web-to-lead form with sample javascript validation:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Web-to-Lead Form</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function submitForm(form) { var errorMsg=""; if( document.getElementById('first_name').value === '' ) {
errorMsg += 'First Name is required.\n'; }
//add other fields to validate here... if( errorMsg === '' ) { return true; } else { alert( "Error:\n\n" + errorMsg ); return false; } } </script> </head> <body> <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" onsubmit="return submitForm( this );" method="POST"> <input type=hidden name="oid" value="xxxx0000000xxxx"> <input type=hidden name="retURL" value="http://successpage.html"> <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
I think your validation formula is not getting fired- IsBlank(FirstName) , try this instead
if(len(trim(FirstName))<1,true,false).