Mobile Validation in PHP website Form Submission

Discussion in 'PHP' started by manioxy, Feb 22, 2013.

  1. #1
    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
     
    manioxy, Feb 22, 2013 IP
  2. sdeveloper

    sdeveloper Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    31
    #2
    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):
     
    sdeveloper, Feb 22, 2013 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    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.
     
    jestep, Feb 22, 2013 IP