Restricting a field to certain characters only

Discussion in 'PHP' started by swapshop, May 21, 2008.

  1. #1
    When our users place a advert they are allowed to fill a url in the form

    Trying to restrict the characters to only allow

    http://www.domain.com

    rather than

    mailto: or @hotmail.com

    using a program called Reg Creator from Program 1

    reg expression I am trying is

    mailto and @
    (\w+)\s+(@\s+)

    and

    /(\w+)\s+(@\s+)/

    I think I am missing what I need to do to restrict mailto and allow http://

    Anyone assist me in the right direction please?
     
    swapshop, May 21, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    Try this


    ^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$

    Regards

    Alex
     
    kmap, May 21, 2008 IP