From b232313c593c7ad2b6f7da0d9bc5f4f0c014fc11 Mon Sep 17 00:00:00 2001 From: Dan Remollino Date: Mon, 7 Apr 2025 10:58:27 -0400 Subject: [PATCH] fixed checkboxes still validating while having no value and marked as optional --- index.html | 2 +- validation.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 457f977..c0592bd 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@
Check Group - + diff --git a/validation.js b/validation.js index ca4fe1e..4174d77 100644 --- a/validation.js +++ b/validation.js @@ -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)