JS Function that Validates Email to IE and Edge

Asked

Viewed 68 times

0

I have a JS code that validates email perfectly and is in use in the portal. No then this function does not work in the IE and/or Edge browser.

function validaEmail(email) {
    var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return regex.test(email);
}

function validaEmail(email) {
    var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return regex.test(email);
}

console.log(validaEmail("Danielle.com"));
console.log(validaEmail("[email protected]"));

  • I opened that page with Edge and IE and they work

  • @Leocaracciolo , thanks for the comment. After your post, I had the idea to put this funciton inside the same JS file and not only reference it as I was doing. Yes... I don’t know why, but it worked. When I separate this function and put it in another file and reference, it works on all other browsers except IE. When placed in the same file there IE can see. Thank you

  • I didn’t understand, calling or not in the js file works the same way in both IE and Edge. See all the code in the js file http://kithomepage.com/sos/danielle.html and the call on the js page http://kithomepage.com/sos/danielle2.html

  • you put the functions, now put the code the way you validate the form to analyze.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.