email validation


/ Published in: JavaScript
Save to your folder(s)

Use a regex to check the email address input


Copy this code and paste it in your HTML
  1. function checkEmail(email) {
  2. var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  3. if (!reg.test(email)) return false;
  4. return true;
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.