Email Validation Done Right
Javascript and PHP code that will verify that an email address at least appears valid and should pass RFC checks.
I have a problem with most email validators on the web. They let through things that are completely wrong. They mark good email addresses as invalid.
Like a plethora of people before me, I have decided to write my own validators. In fact, I decided to write more than one to make sure that they are right and to have an algorithm that will likely work with my language of choice at the moment.
Try It Yourself
Enter an email below and it will validate the email address as you type.
See a mistake? First, confirm with the rules and see where I have gone wrong, then email me! Be forewarned: the rules can be a bit overwhelming.
Download
Here's the email validation rules as source code. Licensing information for each one is included at the top of the file.
- JavaScript - What this page uses for the live form.
- PHP with patterns - Uses PCRE functions to perform email matches.
- PHP without patterns - Same thing, only without any regular expressions.