Skip to content

Commit

Permalink
Fix same error appearing multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
hjvoid committed Aug 28, 2024
1 parent a168858 commit 32794f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/assets/javascripts/browsered/form-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var init = function () {
var errorAnchor = document.createElement('a')
errorAnchor.setAttribute('href', '#' + error.cssKey)
errorAnchor.id = error.cssKey + '-error'
if(!document.getElementById(errorAnchor.id)){
if (!document.getElementById(errorAnchor.id)) {
errorAnchor.innerText = error.value
listElement.appendChild(errorAnchor)
if (addType === 'append') {
Expand Down Expand Up @@ -192,8 +192,14 @@ var init = function () {
if (isAnExpiryDateField) {
expiryMonthElement.classList.remove(CSS_ERROR_CLASS)
expiryYearElement.classList.remove(CSS_ERROR_CLASS)
if (document.getElementById('expiry-month-error')) {
document.getElementById('expiry-month-error').remove()
}
} else {
input.classList.remove(CSS_ERROR_CLASS)
if (document.getElementById(`${input.id}-error`)) {
document.getElementById(`${input.id}-error`).remove()
}
}
}
}
Expand Down

0 comments on commit 32794f9

Please sign in to comment.