fixed checkboxes still validating while having no value and marked as optional
This commit is contained in:
@ -58,7 +58,7 @@
|
||||
<fieldset class="form-group">
|
||||
<legend>Check Group</legend>
|
||||
<span class="form-group__item">
|
||||
<input data-validation='{"maxCount": 2}' id="checkbox-1" type="checkbox" name="checks">
|
||||
<input id="checkbox-1" type="checkbox" name="checks">
|
||||
<label for="checkbox-1">Checkbox 1</label>
|
||||
</span>
|
||||
<span class="form-group__item">
|
||||
|
@ -277,7 +277,7 @@ class Validation {
|
||||
const nameAttrVal = fieldInstance.el.name
|
||||
|
||||
if (!fieldInstance.optional && this.validateForBlank(fieldInstance) ||
|
||||
(fieldInstance.optional && fieldInstance.el.value !== '')) {
|
||||
(fieldInstance.optional && (fieldInstance.el.value !== '' && fieldInstance.el.checked))) {
|
||||
switch (fieldInstance.el.type) {
|
||||
case 'checkbox':
|
||||
this.validateCheckbox(fieldInstance, nameAttrVal)
|
||||
|
Reference in New Issue
Block a user