Search code examples
htmlregexinternet-explorer-11microsoft-edge

Long input pattern validation fails on Edge and IE11


I am checking a email field to include any of the accepted domain names at the end using a long list of those TLDs in the pattern attribute of the <input> field

Here is a shortened version with the middle part excluded:

pattern=".+(\.aaa|\.aarp|\.abarth|\.abb|\.abbott|\.abbvie|\.abc|\.able|\.abogado|\.abudhabi|{...}|\.zuerich|\.zw)"

The pattern is accepted just fine in Chrome and Firefox but Edge and IE11 fail to validate if the match is somewhere in the ".co*" area and later

for example "[email protected]" validates, whereas "[email protected]" does not

Take a look and test here: https://jsfiddle.net/qoalu/Lj0p4ys5/4/


Solution

  • I believe your regular expression is faulty. It failed .abbott and .abbvie but not .abarth, .abb, or .abc. Add a $ at the end between the right parenthesis and the quote. I tested it on IE and Chrome.