I've noticed a lot of requests for Postal Code validation. I don't
know if anyone posted one, but here is an addon method I wrote for
Canadian postal codes.

$.validator.addMethod("postalCode", function(value) { // Addon method
for validating postal codes. Valid formats are (X1X 1X1) or (X1X1X1)
or (X1X-1X1).
        return value.match(/^[a-zA-Z][0-9][a-zA-Z](-| )?[0-9][a-zA-Z]
[0-9]$/);
}, 'Please enter a valid postal code');


You can then use the rule postalCode:true to validate.

Reply via email to