mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-12 14:08:28 +02:00
Update get-gov.js
This commit is contained in:
parent
af656eb5a3
commit
6c6d830e2a
1 changed files with 6 additions and 12 deletions
|
@ -243,9 +243,7 @@ function handleValidationClick(e) {
|
||||||
if (checkAvailabilityButton) {
|
if (checkAvailabilityButton) {
|
||||||
const targetId = checkAvailabilityButton.getAttribute('validate-for');
|
const targetId = checkAvailabilityButton.getAttribute('validate-for');
|
||||||
const checkAvailabilityInput = document.getElementById(targetId);
|
const checkAvailabilityInput = document.getElementById(targetId);
|
||||||
checkAvailabilityButton.addEventListener('click', function() {
|
checkAvailabilityButton.addEventListener('click', removeFormErrors(checkAvailabilityInput));
|
||||||
removeFormErrors(checkAvailabilityInput);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add event listener to the alternate domains input
|
// Add event listener to the alternate domains input
|
||||||
|
@ -254,10 +252,8 @@ function handleValidationClick(e) {
|
||||||
for (const domainInput of alternateDomainsInputs){
|
for (const domainInput of alternateDomainsInputs){
|
||||||
// Only apply this logic to alternate domains input
|
// Only apply this logic to alternate domains input
|
||||||
if (domainInput.classList.contains('alternate-domain-input')){
|
if (domainInput.classList.contains('alternate-domain-input')){
|
||||||
domainInput.addEventListener('input', function() {
|
domainInput.addEventListener('input', removeFormErrors(domainInput));
|
||||||
removeFormErrors(domainInput);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -267,7 +263,7 @@ function handleValidationClick(e) {
|
||||||
*/
|
*/
|
||||||
function removeFormErrors(input){
|
function removeFormErrors(input){
|
||||||
// Remove error message
|
// Remove error message
|
||||||
const errorMessage = document.getElementById(`${input.id}__error-message`);
|
let errorMessage = document.getElementById(`${input.id}__error-message`);
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
errorMessage.remove();
|
errorMessage.remove();
|
||||||
}
|
}
|
||||||
|
@ -277,18 +273,16 @@ function removeFormErrors(input){
|
||||||
input.classList.remove('usa-input--error');
|
input.classList.remove('usa-input--error');
|
||||||
}
|
}
|
||||||
|
|
||||||
const label = document.querySelector(`label[for="${input.id}"]`);
|
let label = document.querySelector(`label[for="${input.id}"]`);
|
||||||
if (label) {
|
if (label) {
|
||||||
label.classList.remove('usa-label--error');
|
label.classList.remove('usa-label--error');
|
||||||
|
|
||||||
// Remove error classes from parent div
|
// Remove error classes from parent div
|
||||||
const parentDiv = label.parentElement;
|
let parentDiv = label.parentElement;
|
||||||
if (parentDiv) {
|
if (parentDiv) {
|
||||||
parentDiv.classList.remove('usa-form-group--error');
|
parentDiv.classList.remove('usa-form-group--error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue