mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-24 12:13:59 +01:00
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:
committed by
Jörn Zaefferer
parent
e147ece02d
commit
07779ae502
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user