How to validate email in jQuery?

No need to apply a lot of conditions for it. You can do it simply using test() function. There are many ways to validate email address but in this way you can keep your code simple with less complexity.

Source Code:

    $(document).ready(function (){
        var email_address = $('input[name=email]').val();

        if( /(.+)@(.+){2,}\.(.+){2,}/.test(email_address) ) {
            alert('This is a valid email');
        } else {
            alert('This is invalid email');

Reviews and Comments