javascript email validation check condition issue

后端 未结 2 1197
日久生厌
日久生厌 2021-01-26 03:48

example,


javascript,

function validateEmail(email         


        
2条回答
  •  悲哀的现实
    2021-01-26 04:47

    Read Stop Validating Email Addresses With Complicated Regular Expressions.

    As it says, this email :

    "Look at all these spaces!"@example.com
    

    is perfectly valid.

    Conclusion :

    1. Don't use a complex regex to validate email. /@/ is fine to check most user errors
    2. Validate by sending an email and waiting for answer

    Seriously, any attempt at solving the problem with a complex regex is doomed and usually keeps being worse with fixes

提交回复
热议问题