choice validator

Check if the number of checked boxes are less or more than a given number


Using with form field

* presents a required option. The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
max data-fv-choice___max* Number The maximum number of check boxes required to be checked
message data-fv-choice___message String The error message
min* data-fv-choice___min or min Number The minimum number of check boxes required to be checked

At least one of min and max option is required.

The validator also supports the select element if the multiple="multiple" attribute is set.

Naming convention

In order to get the correct submit data in the server side, you should pay attention on setting the name attribute of checkbox/select elements.

Server side name attribute Example
PHP name[]

Spring framework name

Basic Example

The following form asks a developer to choose 2-4 programming languages which he/she is good at: