Phone Number Validation Using preg_match() Below code shows validation of Phone Number 1)Checking whether user input (Phone Number) contains an alphabet in Phone Number <?php $mobile_no="123fdgdg890"; if(preg_match("/[a-z][A-Z]/i", $mobile_no)) { echo "Invalid Phone Number!"; }else{ echo "Valid Phone Number!"; } ?> Output :Invalid Phone Number! Syntax preg_match("/[a-z][A-Z]/i", $mobile_no) The above syntax will verify whether given phone number is well-formed or not.if it is not, it will show an error message. The preg_match() function helps to find whether a given variable is valid or not. 2 )Checking whether user input (Phone Number) contains 10 digits in Phone Number <?php...
Comments
Post a Comment