Hello all,
When a new user create an account on our site, what is the easier way to be sure that the zip code is alway entered like :
G8E 5M7 (with capitals letters an a space)
and not like :
g8e5m7
g8e 5m7
G8e 5M7
etc.
Do you have an idea of an easy method to manage it? Or should i dive in python once again?
In my case (custom module) I did it that way:
post = record.buyer_postcode.strip(' ') code = "%s %s" %(post[:-3].strip(), post[-3:]) postcode = code.upper() record.write({'buyer_postcode': postcode.upper()})So if you want you can modify py, add action "Validate" or something ....But in your case it will be better use jQuery as Axel suggested.
Thanks a lot!
post = record.buyer_postcode.strip(' ')# striping postcode to get only string of characters and digits code = "%s %s" %(post[:-3].strip(), post[-3:])#joining it back with one space between postcode = code.upper()# changing to uppercase record.write({'buyer_postcode': postcode.upper()})# writing new value into the field or database