i have created a contatct form.but i am struggling with the validating mobile number.to validat ethis mobile number i have few conditions.
Here is my code
$Mnumber = "94775896789";
if(!empty($Mnumber)) // phone number is not empty
{
if(preg_match('/^?947\d{8}$/',$Mnumber)) // phone number is valid
{
echo 'success';
}
else // phone number is not valid
{
echo 'Phone number invalid !';
}
}
$Mnumber = Str_replace(" ", "", $Mnumber); //optional, if you want to help the user
preg_match("/^(947\d{8})$/", $Mnumber, $reslut);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.