parseField workflow updates; fixed fields not resetting validation state when form is submitted
This commit is contained in:
@ -263,7 +263,8 @@ class Validation {
|
||||
parseField(fieldInstance) {
|
||||
const nameAttrVal = fieldInstance.el.name
|
||||
|
||||
if (this.validateForBlank(fieldInstance)) {
|
||||
if (!fieldInstance.optional && this.validateForBlank(fieldInstance) ||
|
||||
(fieldInstance.optional && fieldInstance.el.value !== '')) {
|
||||
switch (fieldInstance.el.type) {
|
||||
case 'checkbox':
|
||||
this.validateCheckbox(fieldInstance, nameAttrVal)
|
||||
@ -290,7 +291,7 @@ class Validation {
|
||||
}
|
||||
|
||||
validateForBlank(fieldInstance) {
|
||||
if (!fieldInstance.el.value && !fieldInstance.optional) {
|
||||
if (!fieldInstance.el.value) {
|
||||
this.addError(
|
||||
fieldInstance,
|
||||
(fieldInstance.labelText ? fieldInstance.labelText : `Field`) + ` is required.`
|
||||
@ -397,6 +398,8 @@ class Validation {
|
||||
} else {
|
||||
for (const error of this.errors) {
|
||||
updateMarkup(error)
|
||||
error.isValid = true
|
||||
error.messageOutputted = false
|
||||
}
|
||||
this.errors.length = 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user