|
|
@@ -22,6 +22,7 @@ When using this extension make sure you specify the correct url to get the masks
|
|
|
'phone': {
|
|
|
url: "phone-codes/phone-codes.js",
|
|
|
maskInit: "+pp(pp)pppppppp",
|
|
|
+ countrycode: "",
|
|
|
mask: function (opts) {
|
|
|
opts.definitions = {
|
|
|
'p': {
|
|
|
@@ -40,31 +41,38 @@ When using this extension make sure you specify the correct url to get the masks
|
|
|
dataType: 'json',
|
|
|
success: function (response) {
|
|
|
maskList = response;
|
|
|
+ },
|
|
|
+ error: function (xhr, ajaxOptions, thrownError) {
|
|
|
+ alert(thrownError + " - " + opts.url);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
maskList = maskList.sort(function (a, b) {
|
|
|
return (a["mask"] || a) < (b["mask"] || b) ? -1 : 1;
|
|
|
});
|
|
|
+
|
|
|
+ if (opts.countrycode != "") {
|
|
|
+ opts.maskInit = "+" + opts.countrycode + opts.maskInit.substring(3);
|
|
|
+ }
|
|
|
maskList.splice(0, 0, opts.maskInit);
|
|
|
return maskList;
|
|
|
},
|
|
|
nojumps: true,
|
|
|
- nojumpsThreshold: 1
|
|
|
- },
|
|
|
- 'phonebe': {
|
|
|
- alias: "phone",
|
|
|
- url: "phone-codes/phone-be.js",
|
|
|
- maskInit: "+32(pp)pppppppp",
|
|
|
- nojumpsThreshold: 4,
|
|
|
- onBeforeMask: function(value, opts) {
|
|
|
+ nojumpsThreshold: 1,
|
|
|
+ onBeforeMask: function (value, opts) {
|
|
|
var processedValue = value.replace(/^0/g, "");
|
|
|
- if (processedValue.indexOf("32") > 1 || processedValue.indexOf("32") == -1) {
|
|
|
- processedValue = "32" + processedValue;
|
|
|
+ if (processedValue.indexOf(opts.countrycode) > 1 || processedValue.indexOf(opts.countrycode) == -1) {
|
|
|
+ processedValue = opts.countrycode + processedValue;
|
|
|
}
|
|
|
|
|
|
return processedValue;
|
|
|
}
|
|
|
+ },
|
|
|
+ 'phonebe': {
|
|
|
+ alias: "phone",
|
|
|
+ url: "phone-codes/phone-be.js",
|
|
|
+ countrycode: "32",
|
|
|
+ nojumpsThreshold: 4
|
|
|
}
|
|
|
});
|
|
|
return $.fn.inputmask;
|