choice validator
Check if the number of checked boxes are less or more than a given number
← Validators
Options
The validator also supports the select
element if the
multiple="multiple"
attribute is set.
Option |
HTML attribute |
Type |
Description |
max |
data-fv-choice-max |
Number |
The maximum number of check boxes required to be checked. It's a dynamic option |
message |
data-fv-choice-message |
String |
The error message. The dynamic
message is supported |
min |
data-fv-choice-min |
Number |
The minimum number of check boxes required to be checked. It's a dynamic option |
At least one of min
and max
option is required.
When setting options via HTML attributes, remember to
enable the validator by setting data-fv-choice="true".
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 |
|
Example
The following form asks a developer to choose 2-4 programming languages which he/she is
good at: