Regex suitable for validating an address field?

Discussion in 'JavaScript' started by pictureboarduk, Feb 23, 2009.

  1. #1
    Hi,

    I am adding some JavaScript to validate a contactus form, and the javascript for the name and email is fine, but I'm thinking that trying to validate an actual address, such as where a person lives varies so much that forming validation on the field is not really possible.

    Is there a way of doing this at all?

    Thanks go to anyone who can advise me.

    Thank you.
     
    pictureboarduk, Feb 23, 2009 IP
  2. igor398

    igor398 Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use <select>
    <option>
     
    igor398, Mar 22, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    you could have four fields:
    house number / unit number
    street name
    street type (drop down)

    and then your state,postcode,country etc. I have seen this done on some websites.
     
    camjohnson95, Mar 22, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    You could restrict the address field to alphanumeric characters (is there anywhere where there are other characters used?) and make it so it is at least a set number of characters - I dunno what would work, but more than 4, at least? That might work - dunno if it's best practice, as I don't know if it would be possible to have a valid address not matching those criteria.
     
    PoPSiCLe, Mar 23, 2009 IP
  5. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #5
    dimitar christoff, Mar 24, 2009 IP