Use Regular Expression by JavaScript
===============================
1 function validateEmail()
2 {
3 // Value to Validate. Ex. Your EMail Address TextBox
4 var EMailID = document.getElementById('txtEMail').value;
5
6 // Here, we set the Expression to Validate the Value for EMail Address.
7 var EMailValidate = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
8
9 // Test the Validator.
10 if( EMailValidate.test(EMailID))
11 {
12 alert('Right Email Address.');
13 }
14 else
15 {
16 alert('Wrong Email Address.');
17 }
18 }
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment