0

I am trying to check the e-amil address like abc@example.co.uk or a.bc@eyample.com etc

and I am using regular expression like

[a-zA-Z0-9\._]+@[^.]+[a.zA-Z]+\.[a-z{2,5}]+

Can someone suggest how to correct it?

Thank you

user160820
  • 14,866
  • 22
  • 67
  • 94
  • It can be corrected but the best solution would be http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address – AurA Feb 14 '13 at 11:20

4 Answers4

0

See Using a regular expression to validate an email address

and you can try :

[a-zA-Z0-9.!#$%&'*+-/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*
Community
  • 1
  • 1
Dumitru Chirutac
  • 617
  • 2
  • 8
  • 28
0

This should work

Example

var sEmail = txtEmail;

var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

if (filter.test(sEmail)) {
    return true;
}
else {
    return false;
}
David Kirubi
  • 53
  • 1
  • 1
  • 7
0

If you make an input type email in new browsers it will validate to a certain level. It will only look for characters followed by a @ and than a few characters after it.

Validating is to catch user mistakes not to make it harder for users to fill in your form.

automaticoo
  • 868
  • 7
  • 24
0

I want to replace apostrophes "'" with "/" from string.

for example: var str ="te'xt"; want output like this "te/xt"

vikas
  • 11
  • 3