10 examples of 'node js email validation' in JavaScript

Every line of 'node js email validation' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
10function validateEmail (email) {
11 if (email && email.match(/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i)) {
12 return true
13 }
14
15 return false
16}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

20function validate_email(email)
21{
22 var emailReg = /\S+@\S+\.\S+/;
23
24 if(!emailReg.test(email)) {
25 return false;
26 }
27
28 return true;
29}
225function validateEmail(email) {
226 if (email.length <= 0) {
227 return false;
228 }
229 var emailPattern = /\S+@\S+\.\S+/;
230 return emailPattern.test(email);
231}
1export default function validateEmail(email: string) {
2 // tslint:disable-next-line:max-line-length
3 const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
4 return reg.test(email) && email !== '' && email.length > 0;
5}
209function validateEmail(emailTest) {
210 var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
211 if (filter.test(emailTest) && emailTest.length < 99) {
212 return true;
213 } else {
214 return false;
215 }
216}
16function validateEmail(email)
17{
18 var re = /\S+@\S+\.\S+/;
19 return re.test(email);
20}
26function validate_email(email)
27{
28 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
29 return re.test(email);
30}
131function validateEmail(email) {
132 return /^\w+([+\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)
133}
13function validateEmail(email) {
14 const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
15 return re.test(email);
16}
8export function validateEmail(email) {
9 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
10 return re.test(email);
11}

Related snippets