Hello Friends, I have a PHP website. In this website there is one inquire form. In this form i'm add insert your mobile number section. in this section user only fill numeric value not any alphabetic character. if user can press any alphabetic character it dose't insert in this section. So, i want your help and get PHP CODE for this type of Mobile Validation CODE. Thanks, -MO
hope you are know that there are lots of phone numbers formats? for example this format: (xxx) xxx-xxxx and php validation code for this format will be: if (preg_match('/^\(?([2-9]\d{2})(\)?)(-|.|\s)?([1-9]\d{2})(-|.|\s)?(\d{4})$/', $_POST['phone_number']) { ................................ } Code (markup):
HTML5 supports input type=tel which restricts data to a number. It will typically queue a phone to only pull up the numeric keypad as well so they don't have the option of trying to enter alpha characters.