mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-13 04:59:59 +02:00
Rename functions for clarity
This commit is contained in:
parent
5e27ec571d
commit
d2f6988bd8
2 changed files with 12 additions and 12 deletions
|
@ -203,7 +203,7 @@ function handleInputValidation(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** On button click, handles running any associated validators. */
|
/** On button click, handles running any associated validators. */
|
||||||
function handleValidationClick(e) {
|
function validateFieldInput(e) {
|
||||||
const attribute = e.target.getAttribute("validate-for") || "";
|
const attribute = e.target.getAttribute("validate-for") || "";
|
||||||
if (!attribute.length) return;
|
if (!attribute.length) return;
|
||||||
const input = document.getElementById(attribute);
|
const input = document.getElementById(attribute);
|
||||||
|
@ -212,7 +212,7 @@ function handleValidationClick(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleFormsetValidationClick(e, availabilityButton) {
|
function validateFormsetInputs(e, availabilityButton) {
|
||||||
|
|
||||||
// Collect input IDs from the repeatable forms
|
// Collect input IDs from the repeatable forms
|
||||||
let inputs = Array.from(document.querySelectorAll('.repeatable-form input'))
|
let inputs = Array.from(document.querySelectorAll('.repeatable-form input'))
|
||||||
|
@ -247,26 +247,26 @@ function handleFormsetValidationClick(e, availabilityButton) {
|
||||||
for(const input of needsValidation) {
|
for(const input of needsValidation) {
|
||||||
input.addEventListener('input', handleInputValidation);
|
input.addEventListener('input', handleInputValidation);
|
||||||
}
|
}
|
||||||
const alternativeDomainsAvailability = document.getElementById('check-avail-for-alt-domains');
|
const alternativeDomainsAvailability = document.getElementById('validate-alt-domains-availability');
|
||||||
const activatesValidation = document.querySelectorAll('[validate-for]');
|
const activatesValidation = document.querySelectorAll('[validate-for]');
|
||||||
|
|
||||||
for(const button of activatesValidation) {
|
for(const button of activatesValidation) {
|
||||||
// Adds multi-field validation for alternative domains
|
// Adds multi-field validation for alternative domains
|
||||||
if (button === alternativeDomainsAvailability) {
|
if (button === alternativeDomainsAvailability) {
|
||||||
button.addEventListener('click', (e) => {
|
button.addEventListener('click', (e) => {
|
||||||
handleFormsetValidationClick(e, alternativeDomainsAvailability)
|
validateFormsetInputs(e, alternativeDomainsAvailability)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
button.addEventListener('click', handleValidationClick);
|
button.addEventListener('click', validateField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add event listener to the alternate domains input
|
// Clear errors on auto-validated inputs when user reselects input
|
||||||
const alternateDomainsInputs = document.querySelectorAll('[auto-validate]');
|
const autoValidateInputs = document.querySelectorAll('[auto-validate]');
|
||||||
if (alternateDomainsInputs) {
|
if (autoValidateInputs) {
|
||||||
for (const domainInput of alternateDomainsInputs){
|
for (const input of autoValidateInputs){
|
||||||
domainInput.addEventListener('input', function() {
|
input.addEventListener('input', function() {
|
||||||
removeFormErrors(domainInput, true);
|
removeFormErrors(input, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
<div class="margin-bottom-3">
|
<div class="margin-bottom-3">
|
||||||
<button
|
<button
|
||||||
id="check-avail-for-alt-domains"
|
id="validate-alt-domains-availability"
|
||||||
type="button"
|
type="button"
|
||||||
class="usa-button usa-button--outline"
|
class="usa-button usa-button--outline"
|
||||||
validate-for="{{ forms.1.requested_domain.auto_id }}"
|
validate-for="{{ forms.1.requested_domain.auto_id }}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue