You need to sign in to do that
Don't have an account?
Ashley Freiheit
Validate web to lead form
Hello,
I'm creating a web to lead form. One of the fields is supposed to be numeric values only, but I cannot create it as a number field because there cannot be commas in the values. I made it a text field and am attempting to create a validation that only allows numeric values, and doesn't allow the form to be submitted and throws an error to the person filling out the web form. I've added the below code to my form, but I'm not getting an error and leads are being created. Can someone spot check my javascript, as I'm totally new to this. Note: I do have ValidateForm as my form action upon submit.
<script type='text/javascript'>
function ValidateForm() {
if (isNaN(document.getElementById('MemberAccountNumber').value {
alert("Member Account Number must only contain numeric values");
return false;
}
return true;
}
</script>
<script type='text/javascript'>
function ValidateForm() {
if (isNaN(document.getElementById('MemberAccountNumber').value {
alert("Member Account Number must only contain numeric values");
return false;
}
return true;
}
</script>
Thank you
I'm creating a web to lead form. One of the fields is supposed to be numeric values only, but I cannot create it as a number field because there cannot be commas in the values. I made it a text field and am attempting to create a validation that only allows numeric values, and doesn't allow the form to be submitted and throws an error to the person filling out the web form. I've added the below code to my form, but I'm not getting an error and leads are being created. Can someone spot check my javascript, as I'm totally new to this. Note: I do have ValidateForm as my form action upon submit.
<script type='text/javascript'>
function ValidateForm() {
if (isNaN(document.getElementById('MemberAccountNumber').value {
alert("Member Account Number must only contain numeric values");
return false;
}
return true;
}
</script>
<script type='text/javascript'>
function ValidateForm() {
if (isNaN(document.getElementById('MemberAccountNumber').value {
alert("Member Account Number must only contain numeric values");
return false;
}
return true;
}
</script>
Thank you
You are missing a closing parenthesis after document.getElementById('MemberAccountNumber').value.
Make sure to include this JavaScript code within the <script> tags in your HTML web-to-lead form. Additionally, ensure that the form's submit button is calling the ValidateForm() function within the onsubmit attribute, like this:
If this helps , please mark this as Best Answer.
Thank you.
All Answers
You are missing a closing parenthesis after document.getElementById('MemberAccountNumber').value.
Make sure to include this JavaScript code within the <script> tags in your HTML web-to-lead form. Additionally, ensure that the form's submit button is calling the ValidateForm() function within the onsubmit attribute, like this:
If this helps , please mark this as Best Answer.
Thank you.