Validating postal code
To make this work, validate the portions of the postal code individually and then set the field error message accordingly: Note that you might choose to store error messages as form variables.
That way they will be examined by Designer’s spell checker.
For example, the meta character “A” in a picture clause allows any Unicode letter value – whereas a postal code letter is far more restricted: When the user enters an invalid postal code, be as specific as possible in telling them what to fix.
There is a world of difference between: “Invalid postal code” and “Second, fourth and sixth postal characters must be numeric” For the person who typed in a letter “O” instead of a “0” (zero), this will be the clue they need to correct their error.
For example, if you search for a ZIP code with country "US", but that ZIP code is located in the US Virgin Islands, the country returned will be "VI".
Countries are always specified with the ISO 3166-1 alpha-2 country code, such as US, GB, and CA.
The function returns an array with these elements: Each is set to FALSE if a valid response is not possible.
There are several interesting scripting validation techniques that can be demonstrated in the context of a Canadian postal code field.
Hey your regexp is pretty good for Canadian zipcode but i just a question since you are saying Canadian Zip code can't contain certain letters such as: "D, F, I, O, Q or U". now if you copy and paste or maybe just take these letters out of the 3rd and 5th char. I'm not sure if I just made my self look stupid but that's what I came up with. String can Zip Reg Ex1 = "^([0-9A-Za-z][\s-][0-9A-Za-z])$"; String can Zip Reg Ex2 = "^([0-9A-Za-z])$"; if ( (postal Code.trim().matches(can Zip Reg Ex1))