Hi all!
I have a problem with preg_match() to check if an email address is correct. When I use this code
Code:
function ValidateEmail($email)
{
return (preg_match("[\\w\\-]+(\\.[\\w\\-]+)*@[\\w\\-]+(\\.[\\w\\-]+)*\\.[A-Za-z]+", $email)>0) ? true : false;
}
The above returns false to
[email protected] but when I use the same regular expression in javascript
Code:
// convert data to string
var test = this.Trim(String(data));
// Find an email address
var reg = new RegExp("[\\w\\-]+(\\.[\\w\\-]+)*@[\\w\\-]+(\\.[\\w\\-]+)*\\.[A-Za-z]+");
// returns true if the data was an email address
return reg.test(test.toLowerCase()) ? true : false;
it returns true... What am I doing wrong? I've the same problem when I use ereg().
Thanks in advance!
- mega
Moving to C# .NET