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) {
|
parseField(fieldInstance) {
|
||||||
const nameAttrVal = fieldInstance.el.name
|
const nameAttrVal = fieldInstance.el.name
|
||||||
|
|
||||||
if (this.validateForBlank(fieldInstance)) {
|
if (!fieldInstance.optional && this.validateForBlank(fieldInstance) ||
|
||||||
|
(fieldInstance.optional && fieldInstance.el.value !== '')) {
|
||||||
switch (fieldInstance.el.type) {
|
switch (fieldInstance.el.type) {
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
this.validateCheckbox(fieldInstance, nameAttrVal)
|
this.validateCheckbox(fieldInstance, nameAttrVal)
|
||||||
@ -290,7 +291,7 @@ class Validation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validateForBlank(fieldInstance) {
|
validateForBlank(fieldInstance) {
|
||||||
if (!fieldInstance.el.value && !fieldInstance.optional) {
|
if (!fieldInstance.el.value) {
|
||||||
this.addError(
|
this.addError(
|
||||||
fieldInstance,
|
fieldInstance,
|
||||||
(fieldInstance.labelText ? fieldInstance.labelText : `Field`) + ` is required.`
|
(fieldInstance.labelText ? fieldInstance.labelText : `Field`) + ` is required.`
|
||||||
@ -397,6 +398,8 @@ class Validation {
|
|||||||
} else {
|
} else {
|
||||||
for (const error of this.errors) {
|
for (const error of this.errors) {
|
||||||
updateMarkup(error)
|
updateMarkup(error)
|
||||||
|
error.isValid = true
|
||||||
|
error.messageOutputted = false
|
||||||
}
|
}
|
||||||
this.errors.length = 0
|
this.errors.length = 0
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user