Sale is live! Enjoy 70% Off! Use Credit/Debit Cards in India and PayPal outside of India for better experience!

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:

<script>
    $(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');
        }
    });
</script>

Reviews and Comments