Email validation using jQuery

后端 未结 30 2358
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 16:52

I\'m new to jQuery and was wondering how to use it to validate email addresses.

30条回答
  •  鱼传尺愫
    2020-11-22 17:43

    If you have a basic form, just make the input type of email:

    This will work for browsers that use HTML5 attributes and then you do not even need JS. Just using email validation even with some of the scripts above will not do much since:

    some@email.com so@em.co my@fakemail.net

    etc... Will all validate as "real" emails. So you would be better off ensuring that the user has to enter their email address twice to make sure that they put the same one in. But to guarantee that the email address is real would be very difficult but very interesting to see if there was a way. But if you are just making sure that it is an email, stick to the HTML5 input.

    FIDDLE EXAMPLE

    This works in FireFox and Chrome. It may not work in Internet Explorer... But internet explorer sucks. So then there's that...

提交回复
热议问题