validate phone with php form

Discussion in 'Programmer's Corner' started by zimbarak, Aug 8, 2011.

  1. zimbarak

    Thread Starter Active Member

    Feb 8, 2009
    56
    0
    Hello Mates,

    I have the following php code which verify a form validation
    the name and email was verified succefuly but i still have the phone that it might be verified ? any thread on how it wil be done it will be appreciated
    i have tried the if(!preg_match function and didnt work ...However
    again i appreciate your kindly assistance


    function VerifyForm(&$values, &$errors)
    {
    // Do all necessary form verification

    if (strlen($values['name']) == 0)
    $errors['name'] = 'Enter your name';


    // Needs better checking ;)
    if (!ereg('.*@.*\..{2,4}', $values['email']))
    $errors['email'] = 'Email address invalid';
     
  2. zimbarak

    Thread Starter Active Member

    Feb 8, 2009
    56
    0
    Hello again ,

    it seems that no body would like to donate by replying on me ... However
    i have another question which i hope if this time will get few replies ,

    Below is an HTML list box <select name="select" id="select">

    <option>Website Update</option>
    <option>Information Change</option>
    <option>Information Addition</option>
    <option>Product Update</option>
    <option selected="selected">Select contact</option>
    </select>

    i need to make a validation for this list box
    the list box is inside a form with a function which is describe as below
    the validation have succeeded for the name,email,phone,message it will only remain the list box to be validated !
    please i would also thanks if anyone can help in making "message sent" confirmation message to be on the same form

    function VerifyForm(&$values, &$errors)
    {
    // Do all necessary form verification

    if (strlen($values['name']) == 0)
    $errors['name'] = 'Enter your name';


    // Needs better checking ;)
    if (!ereg('.*@.*\..{2,4}', $values['email']))
    $errors['email'] = 'Email address invalid';
    if (strlen($values['text']) == 0)
    $errors['text'] = 'Text Required';

    if (!is_numeric($values['phone'])) {
    $errors['phone'] = 'invalid number';
     
Loading...