With international domain names almost everything is possible:
- Håkan.Söderström@malmö.se
- [email protected]
- 试@例子.测试.مثال.آزمایشی
If you want to do any tests you should first convert it to punycode.
Without punycode all you should do is to test that there:
- is at least one @
- is at least one character in the local part
- is at least one dot in the domain part
- is at least four characters in the domain (assuming that no-one has an address at the tld, that the tld is at least 2 chars)
Here is the code:
function isEmail(address) {
var pos = address.lastIndexOf("@");
return pos > 0 && (address.lastIndexOf(".") > pos) && (address.length - pos > 4);
}
function isEmail(address) {
var pos = address.lastIndexOf("@");
return pos > 0 && (address.lastIndexOf(".") > pos) && (address.length - pos > 4);
}