Possible Duplicate:
Canada postal code validation
I need javascript regex for validating Canadian postal/zip code.
Canada's Postal Code format is 'A1A 1X1' or 'a1a1x1'
. However it doesn't include the letters D, F, I, O, Q, or U.I found few here but those were in C#.
function checkPostal(postal) {
var regex = new RegExp(/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i);
if (regex.test(postal.value))
return true;
else return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With