OPINION : Check validity of email address

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

Post Reply
element121
php-forum Fan User
php-forum Fan User
Posts: 608
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Re: OPINION : Check validity of email address

Post by element121 » Thu Oct 22, 2015 2:38 am

In HTML5 you can use

Code: Select all

<input type="email" required name="email_address">
which saves lots of validation requirements.

Hope that helps,
Jon

User avatar
Strider64
php-forum Active User
php-forum Active User
Posts: 278
Joined: Sat Mar 23, 2013 8:24 am

Re: OPINION : Check validity of email address

Post by Strider64 » Thu Oct 22, 2015 9:56 am

I like K.I.S.S. (Keep It Simple Stupid) ->

Code: Select all

$email = "john.doe@example.com";

if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  echo("$email is a valid email address");
} else {
  echo("$email is not a valid email address");
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest