mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Exclude blank fields
This commit is contained in:
parent
45e994ea05
commit
7045e5dcad
2 changed files with 14 additions and 3 deletions
|
@ -134,10 +134,19 @@ function _checkDomainAvailability(el) {
|
||||||
const callback = (response) => {
|
const callback = (response) => {
|
||||||
toggleInputValidity(el, (response && response.available), msg=response.message);
|
toggleInputValidity(el, (response && response.available), msg=response.message);
|
||||||
announce(el.id, response.message);
|
announce(el.id, response.message);
|
||||||
|
|
||||||
|
// Determines if we ignore the field if it is just blank
|
||||||
|
ignore_blank = el.classList.contains("blank-ok")
|
||||||
if (el.validity.valid) {
|
if (el.validity.valid) {
|
||||||
el.classList.add('usa-input--success');
|
el.classList.add('usa-input--success');
|
||||||
// use of `parentElement` due to .gov inputs being wrapped in www/.gov decoration
|
// use of `parentElement` due to .gov inputs being wrapped in www/.gov decoration
|
||||||
inlineToast(el.parentElement, el.id, SUCCESS, response.message);
|
inlineToast(el.parentElement, el.id, SUCCESS, response.message);
|
||||||
|
} else if (ignore_blank && response.code == "required"){
|
||||||
|
// Visually remove the error
|
||||||
|
error = "usa-input--error"
|
||||||
|
if (el.classList.contains(error)){
|
||||||
|
el.classList.remove(error)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
inlineToast(el.parentElement, el.id, ERROR, response.message);
|
inlineToast(el.parentElement, el.id, ERROR, response.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,11 @@
|
||||||
{# attr_validate / validate="domain" invokes code in get-gov.js #}
|
{# attr_validate / validate="domain" invokes code in get-gov.js #}
|
||||||
{# attr_auto_validate likewise triggers behavior in get-gov.js #}
|
{# attr_auto_validate likewise triggers behavior in get-gov.js #}
|
||||||
{% with append_gov=True attr_validate="domain" attr_auto_validate=True %}
|
{% with append_gov=True attr_validate="domain" attr_auto_validate=True %}
|
||||||
{% for form in forms.1 %}
|
{% with add_class="blank-ok" %}
|
||||||
{% input_with_errors form.alternative_domain %}
|
{% for form in forms.1 %}
|
||||||
{% endfor %}
|
{% input_with_errors form.alternative_domain %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endwith %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue