Email Validation with php and jquery

Generally we are using an email address to know about unique visitors, because email id is unique address of a user and to validate that email id is must for us so that our user information prevent from spammers. Email validation is possible in any scripting language and in this post we will talk about email validation with php as well as jquery. In php we can use preg_match() function to check if the email format is correct or not. We will use the follow codes:

function checkEmail($str) {
    $regex = "/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i";
    $string = trim($str);

   return preg_match($regex, $str)) ? TRUE : FALSE;
}

 

In the above codes we made a function named checkEmail() now we will implement this function to check an email address.

Read More