Movak
Movak

Reputation: 115

codeigniter form validation multiselect limit

I am trying to create a couple of callbacks that set the minimum and maximum number of items that can be selected through a multiselect or a multi checkbox. The problem is that the form input of both of those is an array and the execution recurses on the array. The callback gets executed once for every entry in the form array rather than once for the entire array.

Is there an way around this?

Upvotes: 1

Views: 213

Answers (1)

Hozeis
Hozeis

Reputation: 1742

If I understand your question correctly:

<script>
    for(var x in arrayItems){
    //add item
    if(x == arrayItems.length - 1)//last item
      callbackFunction();
    }
</script>

Upvotes: 1

Related Questions