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>