Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validate() {
- var reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- const inputField = document.getElementById('email');
- inputField.addEventListener('input', function(){
- if(reg.test(inputField.value)){
- inputField.classList.remove('error');
- }else{
- inputField.classList.add('error');
- }
- });
- }
Add Comment
Please, Sign In to add comment