|
|
@@ -3,7 +3,7 @@
|
|
|
* http://github.com/RobinHerbots/jquery.inputmask
|
|
|
* Copyright (c) 2010 - 2014 Robin Herbots
|
|
|
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-* Version: 3.0.2
|
|
|
+* Version: 3.0.3
|
|
|
*/
|
|
|
|
|
|
(function ($) {
|
|
|
@@ -1666,6 +1666,15 @@
|
|
|
}
|
|
|
};
|
|
|
$.fn.inputmask = function (fn, options) {
|
|
|
+ function importAttributeOptions(npt, opts) {
|
|
|
+ var $npt = $(npt);
|
|
|
+ for (var option in opts) {
|
|
|
+ var optionData = $npt.data("inputmask-" + option.toLowerCase());
|
|
|
+ if (optionData != undefined)
|
|
|
+ opts[option] = optionData;
|
|
|
+ }
|
|
|
+ return opts;
|
|
|
+ }
|
|
|
var opts = $.extend(true, {}, $.inputmask.defaults, options),
|
|
|
maskset;
|
|
|
|
|
|
@@ -1679,9 +1688,9 @@
|
|
|
|
|
|
return this.each(function () {
|
|
|
if ($.isArray(maskset)) {
|
|
|
- multiMaskScope(this, maskset, opts);
|
|
|
+ multiMaskScope(this, maskset, importAttributeOptions(this, opts));
|
|
|
} else
|
|
|
- maskScope($.extend(true, {}, maskset), opts, { "action": "mask", "el": this });
|
|
|
+ maskScope($.extend(true, {}, maskset), importAttributeOptions(this, opts), { "action": "mask", "el": this });
|
|
|
});
|
|
|
case "unmaskedvalue":
|
|
|
var $input = $(this), input = this;
|
|
|
@@ -1762,9 +1771,9 @@
|
|
|
if (maskset == undefined) { return this; }
|
|
|
return this.each(function () {
|
|
|
if ($.isArray(maskset)) {
|
|
|
- multiMaskScope(this, maskset, opts);
|
|
|
+ multiMaskScope(this, maskset, importAttributeOptions(this, opts));
|
|
|
} else
|
|
|
- maskScope($.extend(true, {}, maskset), opts, { "action": "mask", "el": this });
|
|
|
+ maskScope($.extend(true, {}, maskset), importAttributeOptions(this, opts), { "action": "mask", "el": this });
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
@@ -1777,9 +1786,9 @@
|
|
|
if (maskset == undefined) { return this; }
|
|
|
return this.each(function () {
|
|
|
if ($.isArray(maskset)) {
|
|
|
- multiMaskScope(this, maskset, opts);
|
|
|
+ multiMaskScope(this, maskset, importAttributeOptions(this, opts));
|
|
|
} else
|
|
|
- maskScope($.extend(true, {}, maskset), opts, { "action": "mask", "el": this });
|
|
|
+ maskScope($.extend(true, {}, maskset), importAttributeOptions(this, opts), { "action": "mask", "el": this });
|
|
|
});
|
|
|
} else if (fn == undefined) {
|
|
|
//look for data-inputmask atribute - the attribute should only contain optipns
|
|
|
@@ -1806,7 +1815,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2014 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 3.0.2
|
|
|
+Version: 3.0.3
|
|
|
|
|
|
Optional extensions on the jquery.inputmask base
|
|
|
*/
|
|
|
@@ -1916,7 +1925,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2014 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 3.0.2
|
|
|
+Version: 3.0.3
|
|
|
|
|
|
Optional extensions on the jquery.inputmask base
|
|
|
*/
|
|
|
@@ -2013,7 +2022,8 @@ Optional extensions on the jquery.inputmask base
|
|
|
cardinality: 2,
|
|
|
prevalidator: [{
|
|
|
validator: function (chrs, buffer, pos, strict, opts) {
|
|
|
- var isValid = opts.regex.val1pre.test(chrs);
|
|
|
+ if (!isNaN(buffer[pos + 1])) chrs += buffer[pos + 1];
|
|
|
+ var isValid = chrs.length == 1 ? opts.regex.val1pre.test(chrs) : opts.regex.val1.test(chrs);
|
|
|
if (!strict && !isValid) {
|
|
|
isValid = opts.regex.val1.test("0" + chrs);
|
|
|
if (isValid) {
|
|
|
@@ -2028,7 +2038,7 @@ Optional extensions on the jquery.inputmask base
|
|
|
},
|
|
|
'2': { //val2 ~ day or month
|
|
|
validator: function (chrs, buffer, pos, strict, opts) {
|
|
|
- var frontValue = buffer.join('').substr(0, 3);
|
|
|
+ var frontValue = (opts.mask.indexOf("2") == opts.mask.length - 1) ? buffer.join('').substr(5, 3) : buffer.join('').substr(0, 3);
|
|
|
if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
|
|
|
var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
|
|
|
if (!strict && !isValid) {
|
|
|
@@ -2040,14 +2050,33 @@ Optional extensions on the jquery.inputmask base
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //check leap yeap
|
|
|
+ if ((opts.mask.indexOf("2") == opts.mask.length - 1) && isValid) {
|
|
|
+ var dayMonthValue = buffer.join('').substr(4, 4) + chrs;
|
|
|
+ if (dayMonthValue != opts.leapday)
|
|
|
+ return true;
|
|
|
+ else {
|
|
|
+ var year = parseInt(buffer.join('').substr(0, 4), 10); //detect leap year
|
|
|
+ if (year % 4 === 0)
|
|
|
+ if (year % 100 === 0)
|
|
|
+ if (year % 400 === 0)
|
|
|
+ return true;
|
|
|
+ else return false;
|
|
|
+ else return true;
|
|
|
+ else return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return isValid;
|
|
|
},
|
|
|
cardinality: 2,
|
|
|
prevalidator: [{
|
|
|
validator: function (chrs, buffer, pos, strict, opts) {
|
|
|
- var frontValue = buffer.join('').substr(0, 3);
|
|
|
+ if (!isNaN(buffer[pos + 1])) chrs += buffer[pos + 1];
|
|
|
+ var frontValue = (opts.mask.indexOf("2") == opts.mask.length - 1) ? buffer.join('').substr(5, 3) : buffer.join('').substr(0, 3);
|
|
|
if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
|
|
|
- var isValid = opts.regex.val2pre(opts.separator).test(frontValue + chrs);
|
|
|
+ var isValid = chrs.length == 1 ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
|
|
|
if (!strict && !isValid) {
|
|
|
isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs);
|
|
|
if (isValid) {
|
|
|
@@ -2182,60 +2211,6 @@ Optional extensions on the jquery.inputmask base
|
|
|
var today = new Date();
|
|
|
$input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString());
|
|
|
}
|
|
|
- },
|
|
|
- definitions: {
|
|
|
- '2': { //val2 ~ day or month
|
|
|
- validator: function (chrs, buffer, pos, strict, opts) {
|
|
|
- var frontValue = buffer.join('').substr(5, 3);
|
|
|
- if (frontValue.indexOf(opts.placeholder[5]) != -1) frontValue = "01" + opts.separator;
|
|
|
- var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
|
|
|
- if (!strict && !isValid) {
|
|
|
- if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
|
|
|
- isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
|
|
|
- if (isValid) {
|
|
|
- buffer[pos - 1] = "0";
|
|
|
- return { "refreshFromBuffer": { start: pos - 1, end: pos }, "pos": pos, "c": chrs.charAt(0) };
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //check leap yeap
|
|
|
- if (isValid) {
|
|
|
- var dayMonthValue = buffer.join('').substr(4, 4) + chrs;
|
|
|
- if (dayMonthValue != opts.leapday)
|
|
|
- return true;
|
|
|
- else {
|
|
|
- var year = parseInt(buffer.join('').substr(0, 4), 10); //detect leap year
|
|
|
- if (year % 4 === 0)
|
|
|
- if (year % 100 === 0)
|
|
|
- if (year % 400 === 0)
|
|
|
- return true;
|
|
|
- else return false;
|
|
|
- else return true;
|
|
|
- else return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return isValid;
|
|
|
- },
|
|
|
- cardinality: 2,
|
|
|
- prevalidator: [{
|
|
|
- validator: function (chrs, buffer, pos, strict, opts) {
|
|
|
- var frontValue = buffer.join('').substr(5, 3);
|
|
|
- if (frontValue.indexOf(opts.placeholder[5]) != -1) frontValue = "01" + opts.separator;
|
|
|
- var isValid = opts.regex.val2pre(opts.separator).test(frontValue + chrs);
|
|
|
- if (!strict && !isValid) {
|
|
|
- isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs);
|
|
|
- if (isValid) {
|
|
|
- buffer[pos] = "0";
|
|
|
- pos++;
|
|
|
- return { "pos": pos };
|
|
|
- }
|
|
|
- }
|
|
|
- return isValid;
|
|
|
- }, cardinality: 1
|
|
|
- }]
|
|
|
- }
|
|
|
}
|
|
|
},
|
|
|
'dd.mm.yyyy': {
|
|
|
@@ -2413,7 +2388,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2014 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 3.0.2
|
|
|
+Version: 3.0.3
|
|
|
|
|
|
Optional extensions on the jquery.inputmask base
|
|
|
*/
|
|
|
@@ -2580,7 +2555,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2014 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 3.0.2
|
|
|
+Version: 3.0.3
|
|
|
|
|
|
Regex extensions on the jquery.inputmask base
|
|
|
Allows for using regular expressions as a mask
|
|
|
@@ -2767,7 +2742,7 @@ Input Mask plugin extensions
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 - 2014 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 3.0.2
|
|
|
+Version: 3.0.3
|
|
|
|
|
|
Phone extension.
|
|
|
When using this extension make sure you specify the correct url to get the masks
|