Additionals: Add postalCodeCA method

Checks for Canadian postal codes using the base regex from
http://geekswithblogs.net/MainaD/archive/2007/12/03/117321.aspx with
additional constraints from
http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp.

- First character must be a valid forward station character
- Must be all caps
- Must use space for forth character

Closes #1118
This commit is contained in:
Nick Schonning
2014-05-16 17:02:42 -04:00
committed by Jörn Zaefferer
parent e147ece02d
commit 07779ae502
3 changed files with 28 additions and 1 deletions

View File

@@ -1205,4 +1205,14 @@ test("currency", function() { // Works with any symbol
ok(!method( "9.99,9", "£"), "Invalid currency" );
});
test("postalCodeCA", function() {
var method = methodTest("postalCodeCA");
ok( method( "H0H 0H0"), "Valid CA Postal Code; Single space" );
ok( !method( "H0H0H0"), "Inalid CA Postal Code; No space" );
ok( !method( "H0H-0H0"), "Invalid CA Postal Code; Single dash" );
ok( !method( "H0H 0H"), "Invalid CA Postal Code; Too Short" );
ok( !method( "Z0H 0H"), "Invalid CA Postal Code; Only 'ABCEGHJKLMNPRSTVXY' are valid starting characters" );
ok( !method( "h0h 0h0"), "Invalid CA Postal Code; Only upper case characters" );
});
})(jQuery);