3 replies [Last post]
yhager's picture
Offline
Joined: 10/01/2007
Juice: 59
Was this information Helpful?

I am looking for a way to validate address fields few examples:

  • Make sure the street is not 'POB'
  • Make sure postal code is 5 numeric in the US, 6 alphanumeric in canada, etc.
  • Phone number validation
  • Email address

I didn't see any _validate functions or hooks to use, and I don't want to hack ubercart core for this, since I guess the validation might be different for each case - I just want to know what you think is the best way to add such code.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6854
Re: Validating address fields

You can try writing a custom module that uses form_alter() to add validate handlers to those fields. I used to have validation on ZIP code and phone numbers, up until people outside of the US started using it.

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
Re: Re: Validating address fields

I think it's quite good to have postal/zip code validation. There is a contribution for osCommerce that I used which uses JavaScript to validate a UK postcode. If a system where implemented it should be able to handle most common postal code formats and be easy to extend to add validation for users.

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
Re: Re: Re: Validating address fields

As well as checking for the correct format and adding a space in the correct place the letters are converted to uppercase.