I have a basic web to lead form. I have created the following javascript code to ensure that a couple of my standard fields are filled in. If they are left blank the javascript error appears, and alerts the person filling out the form. The issue I am running into is the last field I want to validate that it is not left blank, is a custom picklist. The field has an ID rather than a text name, so it's not working with the javascript code I used for the other fields.

Here is the code that works:

function validation(form) {

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

alert('Please enter your first name');
return false;

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

alert('Please enter your last name');
return false;

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

alert('Please enter your email address');
return false;

return true;

Any assistance or direction on how to proceed is greatly appreciated!

Thanks in advance!


Within SFDC, one uses the TEXT() function to transform picklist values into text for evaluation. Is there a similar JS function to convert your picklist values to text so that your == '' test could evaluate them?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.