Quantcast
Channel: Adobe Community : All Content - LiveCycle Designer
Viewing all articles
Browse latest Browse all 5571

Help writing JavaScript using an array to require at least one checkbox is selected prior to Save

$
0
0

I have a group of 29 checkboxes that I need to require at least one be checked prior to someone saving the form. (The validation taking place prior to Saving is critical.) Since there are 29 checkboxes in the group, I’d like to use an array rather than individually addressing each box. Unfortunately this has proved to be beyond my scripting abilities.

Below is the script that I’ve been trying to use/adapt. It doesn’t seem to do anything, and I’m not even sure on which event I should be placing it.

var checkboxVal =false;    

 

for (var i=0; i<WCForm.InjuredBodyPart.length; i++)

{   

 

  if (WCForm.InjuredBodyPart[i].checked) checkboxVal =true;    

 

}    

 

if (!checkboxVal)

{    

 

  alert("Please select at least one Injured Body Part.");    

 

  returnfalse;

} 


Viewing all articles
Browse latest Browse all 5571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>