How can I make certain fields as mandatory in web forms?

You can make certain fields as mandatory in web forms by adding the following code (marked in bold) to your HTML code. Following is an example to make the custom field, Business Type as mandatory. Similarly, you can make any other field mandatory in your web form. 

The image below explains the use of two Arrays while marking fields as mandatory. The Custom Field ID (LEADCF1) will be automatically generated for the custom fields only. 


Following is the sample HTML code:

  1. <div id="zohoWebToLead" align=center><META HTTP-EQUIV ="content-type" CONTENT="text/html;charset = UTF-8">
     

    <script>

    // if you need to have some fields to be mandatory, please add them here within quotes ("") separate by comma (,).

     var fieldIdarray=new Array("Last Name","First Name","Company","LEADCF1"); //This is used for the Validation.

     var fieldNamearray=new Array("Last Name","First Name","Company","Business Type"); //This is used for alert messages.

    function validate()
    {
     for(var i=0;i<fieldIdarray.length;i++)
     {
      var value=document.getElementsByName(fieldIdarray[i])[0].value;
      if(value=="" || value =="-None-" )
       {
       alert(fieldNamearray[i]+" cannot be empty");return false;
       }
      }
    }
    </script>

    <form action="https://crm.zoho.com/crm/WebToLead" method="POST" onSubmit="return validate()">

    <table border=0 cellspacing=0 cellpadding=5 width=480 style="border-top:2px solid
    #999999;border-bottom:1px solid #999999;background-color:#ffffff;"> <input type="hidden" name="xnQsjsdp" value=59SJcg4GHJw$/> 

    <input type="hidden" name="xmIwtLD" value=NFZSAQUHzp32s8DiAVxCKNScuT5roLW2/> 
    <input type="hidden" name="actionType" value=TGVhZHM=/> 
    <input type="hidden" name="returnURL" value="https://www.zoho.com" />

    <tr><td colspan="2" align="left" style="background-color:#f5f5f5;border-bottom:2px dotted #dadada; color:#000000;font-family:sans-serif;font-size:14px;"><strong>Web Form</strong></td></tr>

    <tr><td nowrap style="font-family:sans-serif;font-size:12px;font-weight:bold" align="right" width="25%">Company &nbsp;&nbsp;:</td><td width="75%"><input type="text" maxlength="100" name="Company" /> </td></tr> 

    <tr><td nowrap style="font-family:sans-serif;font-size:12px;font-weight:bold" align="right" width="25%">First Name &nbsp;&nbsp;:</td><td width="75%"><input type="text" maxlength="40" name="First Name" /> </td></tr>

    <tr><td nowrap style="font-family:sans-serif;font-size:12px;font-weight:bold" align="right" width="25%">Last Name &nbsp;&nbsp;:</td><td width="75%"><input type="text" maxlength="80" name="Last Name" /> </td></tr>

    <tr><td nowrap style='font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'>Business Type &nbsp;&nbsp;:</td><td width='75%'><input type='text' maxlength='8' name='LEADCF1' /> </td></tr>

    <tr><td nowrap style="font-family:sans-serif;font-size:12px;font-weight:bold" align="right" width="25%">Phone &nbsp;&nbsp;:</td><td width="75%"><input type="text" maxlength="30" name="Phone" /> </td></tr> 

    <tr><td colspan=2 align=center style="background-color:#eaeaea"> <input type="submit" name="save" value=Save /> &nbsp; &nbsp; <input type="reset" name="reset"value=Reset/></td></tr></table>

    </form>
    </div>



Related Links
Can multiple web forms be created?

How to use hidden fields in the web form?
How do I include captcha in my web form?

Rate this article:
(9 ratings)

Get More Help:

Are you looking for a personalized customer support? Submit your question or Call our Toll Free Number to speak with Zoho CRM Expert who can offer a better solution for your requirements.


Submit your Request

Leave Comments: