Skip to content

Commit

Permalink
made miles driven validation reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Nov 9, 2023
1 parent d6fde02 commit 385811a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/javascript/src/validated_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ class NonDrivingContactMediumWarning extends ValidatableFormSectionComponent {
this.checkboxContainer = this.drivingContactMediumCheckbox.parents('.contact-medium.form-group')
this.milesDrivenInput = milesDrivenInput

allInputs.on('change', (e) => {
this.validate()
})

this.notifier = notifier
}

Expand Down Expand Up @@ -312,7 +316,6 @@ $(() => { // JQuery's callback for the DOM loading

validatedFormCollection.on('submit', function (e) {
let errorCount = 0
let warningCount = 0

for (const validatableFormSectionComponent of validatableFormSectionComponents) {
try {
Expand All @@ -321,10 +324,6 @@ $(() => { // JQuery's callback for the DOM loading
if (validationResult.error) {
errorCount++
}

if (validationResult.warning) {
warningCount++
}
} catch (err) {
console.error('Failed to validate the following component:', validatableFormSectionComponent)
console.error('Validation threw error:', err)
Expand Down

0 comments on commit 385811a

Please sign in to comment.