Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Javascript and PHP Email Validation

Hello Friends,

I have noticed that many developers are facing problem in Form Email validation. Developers are always use to make a JavaScript Email validation and forgot to put server side email validation. As a developer, i suggest to put a server side validation as well. Server side validation is most important if you want to make spamming free web application. Please have a look at both validation code. First is JavaScript Email Validation and second one is PHP Email validation.

// Client side(JavaScript) email validation
function is_valid_email(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
      alert('Invalid Email Address!');
      return false;
// Serverside(PHP) Email Validation
function is_valid_email($email){
  $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
  if (eregi($pattern, $email)){
     return true;
  else {
     return false;

Thank You!

1 Comment

  • sem


    […]Javascript Email Validation | PHP Email Validation | Programming Facts -PHP Freelancer-Indian Freelancer[…]…

Leave a Reply

Your email address will not be published.