Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validate() {
- const inputElement = document.getElementById('email');
- const validMatch = /^[a-z]+@[a-z]+\.[a-z]+$/;
- inputElement.addEventListener('change', (e) => {
- if (!validMatch.test(inputElement.value)) {
- e.currentTarget.classList.add('error');
- } else {
- e.currentTarget.classList.remove('error');
- }
- });
- }
- validate(); // Call the function to set up the event listener
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement