Expekt bonuses - Myspace Layouts - Name tag - Shopping news - Debt Consolidation

PDA

View Full Version : Regex suitable for validating an address field?


pictureboarduk
Feb 23rd 2009, 12:16 pm
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.

igor398
Mar 22nd 2009, 4:11 pm
use <select>
<option>

camjohnson95
Mar 22nd 2009, 7:49 pm
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.

PoPSiCLe
Mar 23rd 2009, 11:31 am
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.

dimitar christoff
Mar 24th 2009, 11:59 am
also try imask - great concept - http://zendold.lojcomm.com.br/imask/

as for address validation, look for PAF (uk based anyway)