Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  179] [ 1]  / answers: 1 / hits: 24311  / 12 Years ago, sun, october 7, 2012, 12:00:00

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#.


More From » regex

 Answers
12
function checkPostal(postal) {
var regex = new RegExp(/^[ABCEGHJKLMNPRSTVXY]d[ABCEGHJKLMNPRSTVWXYZ]( )?d[ABCEGHJKLMNPRSTVWXYZ]d$/i);
if (regex.test(postal.value))
return true;
else return false;
}

[#82711] Friday, October 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominics

Total Points: 424
Total Questions: 99
Total Answers: 107

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
dominics questions
Wed, Apr 6, 22, 00:00, 2 Years ago
Thu, Jan 13, 22, 00:00, 2 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
;