Email validation using jQuery
- By Preneesh AV --
- 12-Dec-2019 --
- 185 Comments
Email validation using jQuery
You can use regular old javascript for that:
function isEmail(email){var regex =/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;return regex.test(email);}
jQuery Function to Validate Email
I really don’t like to use plugins, especially when my form only has one field that needs to be validated. I use this function and call it whenever I need to validate an email form field.
function validateEmail($email){var emailReg =/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;return emailReg.test( $email );}
and now to use this
if(!validateEmail(emailaddress)){/* do stuff here */}