Skip to content

Commit 920f118

Browse files
committed
Added postcodeBR and fixed indentation
1 parent 95f7204 commit 920f118

File tree

1 file changed

+50
-46
lines changed

1 file changed

+50
-46
lines changed

js/contrib/other-validations.js

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,54 @@
44
Use at your own risk. We can't provide support for most of the validations
55
*/
66
(function($){
7-
if($.validationEngineLanguage == undefined || $.validationEngineLanguage.allRules == undefined )
8-
alert("Please include other-validations.js AFTER the translation file");
9-
else {
10-
$.validationEngineLanguage.allRules["postcodeUK"] = {
11-
// UK zip codes
12-
"regex": /^([A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKS-UWa-hjks-uw])\ {0,1}[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}|([Gg][Ii][Rr]\ 0[Aa][Aa])|([Ss][Aa][Nn]\ {0,1}[Tt][Aa]1)|([Bb][Ff][Pp][Oo]\ {0,1}([Cc]\/[Oo]\ )?[0-9]{1,4})|(([Aa][Ss][Cc][Nn]|[Bb][Bb][Nn][Dd]|[BFSbfs][Ii][Qq][Qq]|[Pp][Cc][Rr][Nn]|[Ss][Tt][Hh][Ll]|[Tt][Dd][Cc][Uu]|[Tt][Kk][Cc][Aa])\ {0,1}1[Zz][Zz]))$/,
13-
"alertText": "* Invalid postcode"
14-
};
15-
$.validationEngineLanguage.allRules["postcodeNL"] = {
16-
// NL zip codes | Accepts 1234AA format zipcodes
17-
"regex": /^\d{4}[a-zA-Z]{2}?$/,
18-
"alertText": "* Ongeldige postcode, formaat moet 1234AA zijn"
19-
};
20-
$.validationEngineLanguage.allRules["postcodeUS"] = {
21-
// US zip codes | Accepts 12345 and 12345-1234 format zipcodes
22-
"regex": /^\d{5}(-\d{4})?$/,
23-
"alertText": "* Invalid zipcode"
24-
};
25-
$.validationEngineLanguage.allRules["postcodeDE"] = {
26-
// Germany zip codes | Accepts 12345 format zipcodes
27-
"regex": /^\d{5}?$/,
28-
"alertText": "* Invalid zipcode"
29-
};
30-
$.validationEngineLanguage.allRules["postcodeAT"] = {
31-
// Austrian zip codes | Accepts 1234 format zipcodes
32-
"regex": /^\d{4}?$/,
33-
"alertText": "* Invalid zipcode"
34-
};
35-
$.validationEngineLanguage.allRules["postcodePL"] = {
36-
// Polish zip codes | Accepts 80-000 format zipcodes
37-
"regex": /^\d{2}-\d{3}$/,
38-
"alertText": "* Niepoprawny kod pocztowy, poprawny format to: 12-345"
39-
};
40-
41-
$.validationEngineLanguage.allRules["postcodeJP"] = {
42-
// JP zip codes | Accepts 123 and 123-1234 format zipcodes
43-
"regex": /^\d{3}(-\d{4})?$/,
44-
"alertText": "* 郵便番号が正しくありません"
45-
};
46-
$.validationEngineLanguage.allRules["onlyLetNumSpec"] = {
47-
// Good for database fields
48-
"regex": /^[0-9a-zA-Z_-]+$/,
49-
"alertText": "* Only Letters, Numbers, hyphen(-) and underscore(_) allowed"
50-
};
51-
// # more validations may be added after this point
52-
}
7+
if($.validationEngineLanguage == undefined || $.validationEngineLanguage.allRules == undefined )
8+
alert("Please include other-validations.js AFTER the translation file");
9+
else {
10+
$.validationEngineLanguage.allRules["postcodeUK"] = {
11+
// UK zip codes
12+
"regex": /^([A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKS-UWa-hjks-uw])\ {0,1}[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}|([Gg][Ii][Rr]\ 0[Aa][Aa])|([Ss][Aa][Nn]\ {0,1}[Tt][Aa]1)|([Bb][Ff][Pp][Oo]\ {0,1}([Cc]\/[Oo]\ )?[0-9]{1,4})|(([Aa][Ss][Cc][Nn]|[Bb][Bb][Nn][Dd]|[BFSbfs][Ii][Qq][Qq]|[Pp][Cc][Rr][Nn]|[Ss][Tt][Hh][Ll]|[Tt][Dd][Cc][Uu]|[Tt][Kk][Cc][Aa])\ {0,1}1[Zz][Zz]))$/,
13+
"alertText": "* Invalid postcode"
14+
};
15+
$.validationEngineLanguage.allRules["postcodeNL"] = {
16+
// NL zip codes | Accepts 1234AA format zipcodes
17+
"regex": /^\d{4}[a-zA-Z]{2}?$/,
18+
"alertText": "* Ongeldige postcode, formaat moet 1234AA zijn"
19+
};
20+
$.validationEngineLanguage.allRules["postcodeUS"] = {
21+
// US zip codes | Accepts 12345 and 12345-1234 format zipcodes
22+
"regex": /^\d{5}(-\d{4})?$/,
23+
"alertText": "* Invalid zipcode"
24+
};
25+
$.validationEngineLanguage.allRules["postcodeDE"] = {
26+
// Germany zip codes | Accepts 12345 format zipcodes
27+
"regex": /^\d{5}?$/,
28+
"alertText": "* Invalid zipcode"
29+
};
30+
$.validationEngineLanguage.allRules["postcodeAT"] = {
31+
// Austrian zip codes | Accepts 1234 format zipcodes
32+
"regex": /^\d{4}?$/,
33+
"alertText": "* Invalid zipcode"
34+
};
35+
$.validationEngineLanguage.allRules["postcodePL"] = {
36+
// Polish zip codes | Accepts 80-000 format zipcodes
37+
"regex": /^\d{2}-\d{3}$/,
38+
"alertText": "* Niepoprawny kod pocztowy, poprawny format to: 12-345"
39+
};
40+
$.validationEngineLanguage.allRules["postcodeJP"] = {
41+
// JP zip codes | Accepts 123 and 123-1234 format zipcodes
42+
"regex": /^\d{3}(-\d{4})?$/,
43+
"alertText": "* 郵便番号が正しくありません"
44+
};
45+
$.validationEngineLanguage.allRules["postcodeBR"] = {
46+
// BR zip codes | Accepts 12345-123 format zipcodes
47+
"regex": /^\d{5}(-\d{3})?$/,
48+
"alertText": "* CEP inválido"
49+
};
50+
$.validationEngineLanguage.allRules["onlyLetNumSpec"] = {
51+
// Good for database fields
52+
"regex": /^[0-9a-zA-Z_-]+$/,
53+
"alertText": "* Only Letters, Numbers, hyphen(-) and underscore(_) allowed"
54+
};
55+
// # more validations may be added after this point
56+
}
5357
})(jQuery);

0 commit comments

Comments
 (0)