How to validate non-english (UTF-8) encoded email address in Javascript and PHP?

前端 未结 7 875
无人及你
无人及你 2020-12-06 06:16

Part of a website I am currently working on contains registration process where users have to provide their email address. Just recently I became aware that non-ascii based

相关标签:
7条回答
  • 2020-12-06 07:02

    On this subject I liked this page so much that I set up a blog exposing sites that do validation wrong (contributions gratefully received - don't let yours be on it!).

    As far as using regexes go, those that say "it's wrong", tend to be light on alternatives, and TBH validation to the last letter of the RFC isn't really that critical - for example while noddy+!#$%&'*-/=?+_{}|~test@gmail.com is a perfectly valid address, it's not too unreasonable to reject it given that a surprisingly large proportion of users can't even type 'hotmail' correctly. Some domains are also quite restrictive on user names anyway, particularly hotmail. So I'm in favour of regexes that are demonstrably reasonable, and my favourite source for that is this page, though I don't like their current JS 'winner' and it would help if they set up a public test page.

    jQuery's validate plugin uses this regex which is interestingly constructed, quite similar in style (but smaller!) to the ex-parrot one (actually my ISP!) linked by @powtac .

    0 讨论(0)
提交回复
热议问题