I have used several custom fields in my web to lead form ,and wanna add validation rules to my html form as well.How to achieve such validations.So far,what I 've tried using javascript is enclosed below.But this code is not working as expected,it is not showing any alerts or so.
<body>
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" onsubmit="return ValidateForm()">
<input type=hidden name="oid" value="00Dm00000008iPU"/>
<input type=hidden name="retURL" value="http://www.google.com"/>
Fields that I wanna make required:
<table width="100%" border="0">
<tbody>
<tr>
<td width="24%" align="right">
MerchantID:
</td>
<td width="1%"> </td>
<td width="25%">
<input id="00Nm0000001ABCv" maxlength="20" name="00Nm0000001ABCv" size="20" type="text" />
</td>
<td width="24%" align="right">
Sales Office Name:
</td>
<td width="2%"> </td>
<td width="24%">
<input id="00Nm0000001ABDA" maxlength="50" name="00Nm0000001ABDA" size="20" type="text" />
</td>
</tr>
My Validation javascript :
<script type='text/javascript'>
function ValidateForm() {
var helperMsg = '';
if (document.getElementById("00Nm0000001ABCv").value.length == 0) {
helperMsg += "Please enter Merchant ID \n\r";
}
if (helperMsg.length > 0) {
alert(helperMsg);
return false;
}
return true;
}
</script>
Please help me out in this.