You need to sign in to do that
Don't have an account?

Java Script Validation---Help...
We have a custom field in Sales Force and a have a simple web-to-lead form on our website that uses ringlead to pass the lead to Sales Force.
The Custom ID and Name that Sales Force gave us for inclusion on this form (to be attached to the ‘region’ field) is:
0N30000000mnNj
This is a nightmare for clientside javacript/ajax validation as
IT IS NOT WEB COMPLIENT – name an id should not begin with a digit, should begin only with a letter. please see W3 ‘s website:
http://www.w3.org/TR/html401/types.html#type-id
This is a serious problem as I am unable to write ANY JavaScript validation for this field and subsequently data is lost and leads are not being distributed correctly which is harming our business. Why could sales force not spot this and is there a way to customise this custom field name and id so that at least it starts with a letter???
Has anyone come against this issue and found a work-around in JavaScript validation???
Any help would be greatly appreciated...
Thanks
I'm assuming you've got HTML code like this:
and you're using JavaScript code like this to get whatever value the user has entered into this field:
Instead, use something like this:
Since you're putting the Id in quotes, it doesn't matter that it starts with a number.
Of course, if hte above isn't what you're doing, it might help if you posted the code you're trying to use....
Hi
Thank you So much, I appreciate your reply.
Please find below my code.
Without seeing all of the relevant HTML code, it's a little hard to tell you exactly what to do, but I think the issue is that you need to understand the distinction between HTML tags in your code and the JavaScript representations of them.
Above is an HTML form named "myForm," with an HTML input tag that has the same name and id. There are two ways to access that input tag in JavaScript. One is using the name, and taking advantage of the fact that the document has an element named "myForm" (the form tag) and myForm has an element named "0N30000000mnNj." To write JavaScript to get the value of that input tag and put it into a variable named theValue, you might say this:
(Note that it starts with "var," not "variable" as your code sample said.)
However, the above won't work, because the element's name starts with a digit. So instead, you can use the second way. The second way calls a built-in JavaScript method named getElementById() that says, "find the HTML element with a particular id," and looks like this:
This way uses the HTML input tag's id to find the element, get its value, and put the result in a JavaScript variable named theValue.
Note that JavaScript is case sensitive, so you have to use upper and lower case exactly as given above.
FWIW, this is all pure JavaScript -- there's really nothing Salesforce-y about it.
Good luck!
Hi
I really appreciate your reply, but I already did what you suggested but it does come through.Please find below the html code and java script code.
Java script:
<script language="javascript">
function validate(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("You didn't enter an email address.\n");
form.email.focus();
return false;
}
if(form.country.value == '') {
alert('Please enter your country');
form.country.focus();
return false;
}
var stripped = phone.value.replace(/[\(\)\.\ ]/g, '');
if (form.phone.value =='') {
alert("Please enter your phone number.\n");
form.phone.focus();
return false;
}
else if (isNaN(parseInt(stripped))) {
alert("The phone number contains illegal characters.\n");
form.phone.focus();
return false;
}
else if (!(stripped.length == 12)) {
alert("The phone number is the wrong length. Make sure you included an country code in the format Country Code-xxx-xxx-xxxx.\n");
form.phone.focus();
return false
}
var interest = document.getElementById('00NA00000076xL2');
if(form.interest.value == '') {
alert('Please select your Program of Interest');
form.interest.focus();
return false;
}
return true;
}
</script>
HTML:
Change
to:
The first statement defines a JavaScript variable named "interest" and sets it up to refer to the HTML element. The second statement compares the value of that variable to an empty string.
Your version of the code wasn't ever referencing the JavaScript variable.