Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- issues with javascript form validation on web to l...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
issues with javascript form validation on web to lead page
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-13-2012 09:46 AM
i have web to lead page that includes some javascript code used to validate email addresses and verify all fields are filled out. the page routes to a record type but when the javascript validation is included it blocks the routing.
here is the HTML that includes the javascript that references the validation code:
<form name="information" action= "https://www.salesforce.com/servlet/servlet.WebToLe
when i take out 'onsubmit="return validateForm();” ' the information is routed to the correct record type but it wont validate the email or that the fields are filled out. the javascript code is accessed by this command.
here is the javascript code:
<script>
function validateForm()
{
var x=document.forms["information"]["first_name"].valu e;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
var x=document.forms["information"]["last_name"].value ;
if (x==null || x=="")
{
alert("Last name must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
if (x==null || x=="")
{
alert("Email must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
var x=document.forms["information"]["confirm_email"].v alue;
if (x==null || x=="")
{
alert("Confirm email must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
var pass= document.getElementById("email").value
var confPass = document.getElementById("confirm_email").value
if(pass != confPass) {
alert('Email fields do not match');
return false;
}
var x=document.forms["information"]["company"].value;
if (x==null || x=="")
{
alert("Company must be filled out");
return false;
}
var x=document.forms["information"]["state"].value;
if (x==null || x=="")
{
alert("State/Province must be filled out");
return false;
}
}
</script>
Re: issues with javascript form validation on web to lead page
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2013 01:03 PM - edited 03-21-2013 01:04 PM
Change the next lines:
var pass= document.getElementById("email").value
var confPass = document.getElementById("confirm_email").valueFor this:
var pass= document.forms["information"]["email"].value; var confPass = document.forms["information"]["confirm_email"].value;
And should solve your problem.
PD: Better late than never :P
Re: issues with javascript form validation on web to lead page
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2013 01:19 PM
Thanks Pepiño i will give this a shot.

