You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
575 B
25 lines
575 B
export default { |
|
init() { |
|
// JavaScript to be fired on the home page |
|
|
|
// Props to Dave Rupert: https://daverupert.com/2017/11/happier-html5-forms/ |
|
const inputs = document.querySelectorAll( 'input, textarea' ); |
|
|
|
inputs.forEach( input => { |
|
input.addEventListener( |
|
'invalid', |
|
event => { |
|
input.classList.add( 'error' ); |
|
}, |
|
false |
|
); |
|
input.addEventListener( 'focus', function () { |
|
input.classList.remove( 'error' ); |
|
} ); |
|
input.addEventListener( 'blur', function () { |
|
input.checkValidity(); |
|
} ); |
|
} ); |
|
}, |
|
finalize() {}, |
|
};
|
|
|