Use js to set focus on first invalid contact form field.
This commit is contained in:
parent
66c84b8a9b
commit
1ae3fd8ab9
1 changed files with 6 additions and 2 deletions
|
|
@ -31,8 +31,12 @@
|
||||||
{ once: true },
|
{ once: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mark the form as submitted.
|
form.addEventListener('submit', function (e) {
|
||||||
button.addEventListener('click', () => form.classList.add('js-submitted'));
|
// Set focus on first invalid field.
|
||||||
|
if (!e.target.validity.valid) {
|
||||||
|
form.querySelector(':invalid').focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Display messages.
|
// Display messages.
|
||||||
if (location.search.substring(1) !== '') {
|
if (location.search.substring(1) !== '') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue