elclanrs / jq-idealforms-old

The ultimate framework for building and validating responsive HTML5 forms.
665 stars 95 forks source link

Email matching not accurate #157

Closed boomkin closed 11 years ago

boomkin commented 11 years ago

Hello, I am using the required email filter and it matches anything@anything without having to type the domain part. I already replaced the regex with another one and its working fine. Just wanted to report this.Thanks.

elclanrs commented 11 years ago

The domain part is actually not a requirement. The regex used /[^@]+@[^@]/ is enough to catch most common errors. All of these are valid email addresses:

niceandsimple@example.com
very.common@example.com
a.little.lengthy.but.fine@dept.example.com
disposable.style.email.with+symbol@example.com
user@[IPv6:2001:db8:1ff::a0b:dbd0]
"much.more unusual"@example.com
"very.unusual.@.unusual.com"@example.com
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
postbox@com (top-level domains are valid hostnames)
admin@mailserver1 (local domain name with no TLD)
!#$%&'*+-/=?^_`{}|~@example.org
"()<>[]:,;@\\\"!#$%&'*+-/=?^_`{}| ~.a"@example.org
" "@example.org (space between the quotes)

Of course, most of the above are not very common, but in any case you'd do your validation on the backend as well, and send an actual email for confirmation.