-2

Possible Duplicate:
How to use a regular expression to validate an email addresses?

I have tried all the standard options, but none have helped with email: blablabla-K@kiev.foxtrot.ua

client function for my custom validator in asp.net webforms:

function requiredFields(source, args) {

                var reg = new RegExp('/^(([^<>()[\]\\.,;:\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,}))$/');

                var email = $('#tbEmail').val();
                args.IsValid = ((email.length > 0) && (reg.test(email)));
 }
Community
  • 1
  • 1
drup
  • 365
  • 3
  • 10
  • See this question: http://stackoverflow.com/questions/201323/how-to-use-a-regular-expression-to-validate-an-email-addresses – Serge Jun 05 '12 at 14:30
  • You can also check here: http://stackoverflow.com/questions/46155/validate-email-address-in-javascript – Chango Jun 05 '12 at 14:35
  • thank u. tried second answer - excelent :) – drup Jun 05 '12 at 14:50

1 Answers1

0
<script type="text/javascript">
$(document).ready(function() {
  $('#txtEmail').blur(function() {
  if(validateEmail('txtEmail'))
  {
      alert('Email is valid');
  }
  else
  {
      alert('Invalid Email Address');
  }
 });
});
function validateEmail(txtEmail){
   var a = document.getElementById(txtEmail).value;
   var filter = /^((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*?)\s*;?\s*)+/;
if(filter.test(a)){
    return true;
}
else{
    return false;
}
}
</script>

Email Address:

< input type='text' id='txtEmail' />

For Live Demo Click Here1

dLcreations
  • 357
  • 2
  • 14