Email validation using jQuery

后端 未结 30 2219
被撕碎了的回忆
被撕碎了的回忆 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

    Another simple and complete option:

    
    
    function IsEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } $("#ValidMail").click(function () { $('span', '#ClasSpan').empty().remove(); if (IsEmail($("#Email").val())) { //aqui mi sentencia } else { $('#ClasSpan').append('Please enter a valid email'); $('#Email').keypress(function () { $('span', '#itemspan').empty().remove(); }); } });

提交回复
热议问题