choice validator
Check if the number of checked boxes are less or more than a given number
Options
Using with form field
(* denotes a required option)
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[] | <input type="checkbox" name="languages[]" /> |
| | <select name="editors[]" multiple="multiple"> |
Spring framework | name | <input type="checkbox" name="languages" /> |
| | <select name="editors" multiple="multiple"> |
Basic example
The following form asks a developer to choose 2-4 programming languages which he/she is good at:
See also
Changelog