mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-06 11:13:21 +02:00
Logic to remove stale alerts
This commit is contained in:
parent
4c5d8b2c55
commit
0a1da49c33
1 changed files with 13 additions and 3 deletions
|
@ -236,7 +236,7 @@ function handleValidationClick(e) {
|
|||
const checkAvailabilityInput = document.getElementById(targetId);
|
||||
checkAvailabilityButton.addEventListener('click',
|
||||
function() {
|
||||
removeFormErrors(checkAvailabilityInput)
|
||||
removeFormErrors(checkAvailabilityInput, true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ function handleValidationClick(e) {
|
|||
// Only apply this logic to alternate domains input
|
||||
if (domainInput.classList.contains('alternate-domain-input')){
|
||||
domainInput.addEventListener('input', function() {
|
||||
removeFormErrors(domainInput);
|
||||
removeFormErrors(domainInput, true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ function handleValidationClick(e) {
|
|||
/**
|
||||
* Removes form errors surrounding a form input
|
||||
*/
|
||||
function removeFormErrors(input){
|
||||
function removeFormErrors(input, removeStaleAlerts=false){
|
||||
// Remove error message
|
||||
let errorMessage = document.getElementById(`${input.id}__error-message`);
|
||||
if (errorMessage) {
|
||||
|
@ -284,6 +284,16 @@ function removeFormErrors(input){
|
|||
parentDiv.classList.remove('usa-form-group--error');
|
||||
}
|
||||
}
|
||||
|
||||
if (removeStaleAlerts){
|
||||
let staleAlerts = document.getElementsByClassName("usa-alert--error")
|
||||
for (let alert of staleAlerts){
|
||||
// Don't remove the error associated with the input
|
||||
if (alert.id !== `${input.id}--toast`) {
|
||||
alert.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue