+ Start a Discussion
SF DakshendraSF Dakshendra 

IF i have 10 Checkboxes fields in web to lead form, If i dont select atleast 1 checkbox i need a message how can i get that?

Hi
If i have 10 Checkboxes fields in web to lead form, If i selcet atleast 1 checkbox thats worked but if i didnt select atleast 1 checkbox i need a message "please select atleast one item" how can i get that in web to lead form?

Thanks
Dakshendra.R
SandhyaSandhya (Salesforce Developers) 
Hi Dakshendra,

Since these are the client side validation rules we need to use Java Script. Include the below code in a script tag and call it in submit button
<script>
var isanyselected=false;
var comparestring="";

function myfunction(val){
if(comparestring.indexOf(val) != -1){
comparestring=comparestring.replace(val,'');
}
else
comparestring  = comparestring  + val;
if(comparestring  == "") isanyselected=false; else isanyselected=true;
}

function submitbuttonclicked(){
return isanyselected;
}
</script>
  
<form onsubmit="myfunction()">
  Enter name: <input type="text">
  <input type="submit">
</form>



Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya