validating form input

Discussion in 'PHP' started by rojojat, Nov 20, 2008.

  1. #1
    Hi,
    I am looking to validate a street address input. Allowing Uppercase,lowercase,numeric, and spaces only. The following allows uppercase,lowercase,and underscores only.

    if (!preg_match('/^[a-z\d_]{1,28}$/i', $address))

    What do I need to add to allow for spaces?

    Thanks.
     
    rojojat, Nov 20, 2008 IP
  2. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if i'm not mistaken, you should use \s

    if (!preg_match('/^[a-z\d_\s]{1,28}$/i', $address))
     
    shineDarkly, Nov 20, 2008 IP
  3. rojojat

    rojojat Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ThankYou very much, that works.
     
    rojojat, Nov 20, 2008 IP
  4. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    no worries mate :)
     
    shineDarkly, Nov 20, 2008 IP