2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.validate.ca"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.validate.ca"] = true;
|
|
|
3 |
dojo.provide("dojox.validate.ca");
|
|
|
4 |
|
|
|
5 |
dojo.require("dojox.validate._base");
|
|
|
6 |
|
|
|
7 |
dojox.validate.ca.isPhoneNumber = function(/* String */value) {
|
|
|
8 |
// summary: Validates 10 Canadian digit phone number for several common formats
|
|
|
9 |
// returns: Boolean
|
|
|
10 |
return dojox.validate.us.isPhoneNumber(value); // same as US
|
|
|
11 |
};
|
|
|
12 |
|
|
|
13 |
dojox.validate.ca.isProvince = function(/* String[2] */value) {
|
|
|
14 |
// summary: Validates Canadian province abbreviations (2 chars)
|
|
|
15 |
// returns: Boolean
|
|
|
16 |
var re = new RegExp("^" + dojox.regexp.ca.province() + "$", "i");
|
|
|
17 |
return re.test(value);
|
|
|
18 |
};
|
|
|
19 |
|
|
|
20 |
dojox.validate.ca.isSocialInsuranceNumber = function(/* String */value) {
|
|
|
21 |
// summary: Validates Canadian 9 digit social insurance number for several common formats
|
|
|
22 |
// This routine only pattern matches and does not use the Luhn Algorithm to validate number.
|
|
|
23 |
// returns: Boolean
|
|
|
24 |
var flags = {
|
|
|
25 |
format: [
|
|
|
26 |
"###-###-###",
|
|
|
27 |
"### ### ###",
|
|
|
28 |
"#########"
|
|
|
29 |
]
|
|
|
30 |
};
|
|
|
31 |
return dojox.validate.isNumberFormat(value, flags);
|
|
|
32 |
};
|
|
|
33 |
|
|
|
34 |
dojox.validate.ca.isPostalCode = function(value) {
|
|
|
35 |
// summary: Validates Canadian 6 digit postal code:
|
|
|
36 |
// Canadian postal codes are in the format ANA NAN,
|
|
|
37 |
// where A is a letter and N is a digit, with a space
|
|
|
38 |
// separating the third and fourth characters.
|
|
|
39 |
// returns: Boolean
|
|
|
40 |
var re = new RegExp("^" + dojox.regexp.ca.postalCode() + "$", "i");
|
|
|
41 |
return re.test(value);
|
|
|
42 |
};
|
|
|
43 |
|
|
|
44 |
}
|