0

I need to get the details of the user with a form.
One of the textboxes is email.
How to validate that an input is email using JavaScript functions?
I'm new to html to go easy on me.

Ramsharan
  • 2,054
  • 2
  • 22
  • 26
  • http://stackoverflow.com/questions/46155/validate-email-address-in-javascript – Malcor Apr 12 '15 at 14:01
  • 1
    If you use [`input type="email"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input), the browser will do the validation for you. (Also remember you always need to validate server-side either way.) – Ulrich Schwarz Apr 12 '15 at 16:00

1 Answers1

0
function isValid(email) {
  var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  return regex.test(email);
}

Validate email address in JavaScript?

Community
  • 1
  • 1
Mihail Petkov
  • 1,535
  • 11
  • 11