Help with my validation script

Discussion in 'PHP' started by Steven Johns, May 19, 2011.

  1. #1
    Hey all,

    I need some help with my validation script, lines 51-57.

    http://codepad.org/AFD78eI8

    It is not functioning correctly.

    I would also like to be able to save the selected checkboxes if errors appear as i've done with the text boxes.

    Any help would be very appreciated.
     
    Steven Johns, May 19, 2011 IP
  2. Steven Johns

    Steven Johns Member

    Messages:
    74
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #2
    The validation rules are as follows:
    • Name field must have a value, contain only alphabetic characters or the space character.
    • The customer id field must have a value, contain only numeric characters and be exactly 6 digits long.
    • At least 1, but no more than 3, checkboxes must be selected from the list of hobbies.
    • If the other checkbox is selected then there must be a value in the associated text field, otherwise this text field must be empty.

    I'm sure this would be very basic for many of you.
     
    Steven Johns, May 19, 2011 IP
  3. Steven Johns

    Steven Johns Member

    Messages:
    74
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #3
    I need this done ASAP, so I will now offer cash via paypal to the person that can correct it. Inbox me with how much you would charge.
     
    Steven Johns, May 19, 2011 IP
  4. KastorPM

    KastorPM Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <input type="checkbox" name="hobbies[other]" id="cbx1" value="1" /><label for="cbx7">Other</label> <br/>
    if(isset($_POST['hobbies']['other'])) {
    // ... do something ...
    }
     
    KastorPM, May 19, 2011 IP
  5. Steven Johns

    Steven Johns Member

    Messages:
    74
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #5
    Ah I ended up getting help elsewhere.

    The problem with it is that the checkbox's real name was hobbies[] and not hobbies[other]- other was the value and i didn't know how else to call it.

    Thanks anyway though.
     
    Steven Johns, May 20, 2011 IP