Hi

I have tried using PHP's native email validation but it does not allow apostrophes in email addresses:

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {

}

I have also tried a regex:

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {

}

and this too does not allow apostrophes in email address (e.g. john.o'shay@myemail.com)

Can anyone provide me with a solution to this problem please?

Many thanks for reading
kbc

    [man]filter_var[/man] returns the filtered variable, not a boolean. But either way: Works For Me.

    echo filter_var("john.o'shay@myemail.com", FILTER_VALIDATE_EMAIL);
      Write a Reply...