samedi 18 avril 2015

How to validate at least one checkbox in Magento?

I have a dynamic form with minimum one checkbox as an array.



<form action="url" method="post" id="whatever">
<input class="checkbox" type="checkbox" name="item_ids[]" value="101" />
<input class="checkbox" type="checkbox" name="item_ids[]" value="102" />
<input class="checkbox validate-one-required" type="checkbox" name="item_ids[]" value="103" />
<button type="submit">
</form>

<script type="text/javascript">
//< ![CDATA[
var customForm = new VarienForm('whatever');
//]]>
</script>


I tried to use the hint from several forums to add the "validate-one-required" to the last checkbox in the group. But when I try to submit my form and I checked the first checkbox Magento told me that I have to select at least one option. Funny! I guess I did it.


Is there something else especially in the javascript area I had to add?


Aucun commentaire:

Enregistrer un commentaire