Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want email validation



sai@yahoo.co.in
but not like below one it have restrict can u guide
sail@yahoo.co.in.in or send any snippets and also for url
Posted
Updated 30-Apr-12 2:11am
v3
Comments
Nilesh Patil Kolhapur 30-Apr-12 8:49am    
accept the solution's if its working for u. so it will help others

Try this:
Java
function validate(form_id,email) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {

      alert('Invalid Email Address');
      return false;
   }
}


and have a look on some references:
Validate multiple email id's using javascript[^]
Validate multiple email id's using javascript[^]
 
Share this answer
 
v2
Hi,

try following javascript

XML
<script language="javascript">
function checkEmail() {
var email = document.getElementById('emailaddress');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
}
</script>


Best Luck
Happy Coding:)
 
Share this answer
 
you can aslo use RegularExpressionValidator
ASP.NET
<asp:regularexpressionvalidator id="regexEmailValid" runat="server" validationexpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" controltovalidate="tbEmail" errormessage="Invalid Email Format" xmlns:asp="#unknown"></asp:regularexpressionvalidator>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900