views:

76

answers:

1

Based on the backend data i may have n number of items displayed along with the check box and textarea for selecting and give commnet on the page and there is also a option given to the user to remove the items based on the requirements. I need to set a validation like atlease one item is required. Since its number is based on the query dont know how to set the validation.

+1  A: 

It's hard to say without a bit more detail, but in general if you have a set of checkboxes and you want to make sure at least one is checked you could do this in your HTML:

<p><input type="checbox" name="my_field_name[]" value="item1" />Item 1</p>
<p><input type="checbox" name="my_field_name[]" value="item2" />Item 2</p>
<p><input type="checbox" name="my_field_name[]" value="item3" />Item 3</p>

and just set a rule that "my_field_name" is a required field. That's assuming it works for you to have the values returned in one array like that.

thegibson