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.
Asked
Active
Viewed 52 times
0

Ramsharan
- 2,054
- 2
- 22
- 26

user4770943
- 11
- 2
-
http://stackoverflow.com/questions/46155/validate-email-address-in-javascript – Malcor Apr 12 '15 at 14:01
-
1If 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 Answers
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);
}

Community
- 1
- 1

Mihail Petkov
- 1,535
- 11
- 11