PHP Validation Digest

Email:

function is_valid_email($email) {
       $result = TRUE;
       if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
           $result = FALSE;
       }
       return $result;
   }
Moblie:
function is_valid_mobile($mobile) {
    $result = TRUE;
    if(preg_match("/[^0-9]/", $mobile))
    {
        $result = FALSE;
    }
    elseif(strlen($mobile)!=11)
    {
        $result = FALSE;
    }
    elseif(substr($mobile,0,2)!="09")
    {
        $result = FALSE;
    }

    return $result;
}

Leave a Reply

Your email address will not be published. Required fields are marked *