1function validateEmail (emailAdress)
2{
3 let regexEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
4 if (emailAdress.match(regexEmail)) {
5 return true;
6 } else {
7 return false;
8 }
9}
10
11let emailAdress = "test@gmail.com";
12console.log(validateEmail(emailAdress));
13
1function validateEmail(email) {
2 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,}))$/;
3 return re.test(String(email).toLowerCase());
4}
5
1function validateEmail(email)
2 {
3 var re = /\S+@\S+\.\S+/;
4 return re.test(email);
5 }
6
7console.log(validateEmail('anystring@anystring.anystring'));
1function validateEmail(email) {
2 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,}))$/;
3 return re.test(String(email).toLowerCase());
4}
5
1function validateEmail(email) {
2 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,}))$/;
3 return re.test(String(email).toLowerCase());
4}
5
1 // Html form call function name at submit button
2
3 <form name="form1" action="#">
4 <input type='text' name='text1'/>
5 <input type="submit" name="submit" value="Submit"
6 onclick="ValidateEmail(document.form1.text1)"/>
7 </from>
8
9 // Write the function name ValidateEmail below
10
11 <script>
12 function ValidateEmail(inputText)
13 {
14 var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
15 if(inputText.value.match(mailformat))
16 {
17 alert("Valid email address!");
18 document.form1.text1.focus();
19 return true;
20 }
21 else
22 {
23 alert("You have entered an invalid email address!");
24 document.form1.text1.focus();
25 return false;
26 }
27 }
28 </script>
29