Browse Source

added non negative integer + set default separator as ""

Robin Herbots 12 years ago
parent
commit
832e40ae4e

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 2
 build.major = 2
 build.minor = 2
 build.minor = 2
-build.revision = 7
+build.revision = 8
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.2.2.7.nupkg


BIN
dist/jQuery.InputMask.2.2.8.nupkg


+ 21 - 8
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.2.7
+* Version: 2.2.8
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -1342,7 +1342,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.7
+Version: 2.2.8
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1439,7 +1439,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.7
+Version: 2.2.8
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1932,7 +1932,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.7
+Version: 2.2.8
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1946,7 +1946,7 @@ Optional extensions on the jquery.inputmask base
             greedy: false,
             greedy: false,
             numericInput: true,
             numericInput: true,
             digits: "*", //numer of digits
             digits: "*", //numer of digits
-            groupSeparator: ",", // | "."
+            groupSeparator: "",//",", // | "."
             radixPoint: ".",
             radixPoint: ".",
             groupSize: 3,
             groupSize: 3,
             autoGroup: false,
             autoGroup: false,
@@ -1964,11 +1964,13 @@ Optional extensions on the jquery.inputmask base
                 return calculatedLength + groupOffset;
                 return calculatedLength + groupOffset;
             },
             },
             postFormat: function (buffer, pos, reformatOnly, opts) {
             postFormat: function (buffer, pos, reformatOnly, opts) {
+                if (opts.groupSeparator == "") return pos;
                 var cbuf = buffer.slice();
                 var cbuf = buffer.slice();
                 if (!reformatOnly) cbuf.splice(pos, 0, "?"); //set position indicator
                 if (!reformatOnly) cbuf.splice(pos, 0, "?"); //set position indicator
                 var bufVal = cbuf.join('');
                 var bufVal = cbuf.join('');
                 if (opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
                 if (opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
-                    bufVal = bufVal.replace(new RegExp("\\" + opts.groupSeparator, "g"), '');
+                    var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
+                    bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), '');
                     var radixSplit = bufVal.split(opts.radixPoint);
                     var radixSplit = bufVal.split(opts.radixPoint);
                     bufVal = radixSplit[0];
                     bufVal = radixSplit[0];
                     var reg = new RegExp('([-\+]?[\\d\?]+)([\\d\?]{' + opts.groupSize + '})');
                     var reg = new RegExp('([-\+]?[\\d\?]+)([\\d\?]{' + opts.groupSize + '})');
@@ -2026,8 +2028,10 @@ Optional extensions on the jquery.inputmask base
 
 
                         cbuf.splice(pos + 1, 0, chrs);
                         cbuf.splice(pos + 1, 0, chrs);
                         var bufferStr = cbuf.join('');
                         var bufferStr = cbuf.join('');
-                        if (opts.autoGroup && !strict) //strip groupseparator
-                            bufferStr = bufferStr.replace(new RegExp("\\" + opts.groupSeparator, "g"), '');
+                        if (opts.autoGroup && !strict) { //strip groupseparator
+                            var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
+                            bufferStr = bufferStr.replace(new RegExp(escapedGroupSeparator, "g"), '');
+                        }
                         var isValid = opts.regex.number(opts.groupSeparator, opts.groupSize, opts.radixPoint, opts.digits).test(bufferStr);
                         var isValid = opts.regex.number(opts.groupSeparator, opts.groupSize, opts.radixPoint, opts.digits).test(bufferStr);
                         if (!isValid) {
                         if (!isValid) {
                             //let's help the regex a bit
                             //let's help the regex a bit
@@ -2086,6 +2090,15 @@ Optional extensions on the jquery.inputmask base
                 }
                 }
             },
             },
             alias: "decimal"
             alias: "decimal"
+        },
+        'non-negative-integer': {
+            regex: {
+                number: function (groupSeparator, groupSize) {
+                    var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, groupSeparator);
+                    return new RegExp("^[\+]?(\\d+|\\d{1," + groupSize + "}((" + escapedGroupSeparator + "\\d{" + groupSize + "})?)+)$");
+                }
+            },
+            alias: "integer"
         }
         }
     });
     });
 })(jQuery);
 })(jQuery);

File diff suppressed because it is too large
+ 59 - 58
dist/jquery.inputmask.bundle.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/jquery.inputmask.js


File diff suppressed because it is too large
+ 7 - 6
dist/min/jquery.inputmask.numeric.extensions.js


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "2.2.7",
+    "version": "2.2.8",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 17 - 4
js/jquery.inputmask.numeric.extensions.js

@@ -17,7 +17,7 @@ Optional extensions on the jquery.inputmask base
             greedy: false,
             greedy: false,
             numericInput: true,
             numericInput: true,
             digits: "*", //numer of digits
             digits: "*", //numer of digits
-            groupSeparator: ",", // | "."
+            groupSeparator: "",//",", // | "."
             radixPoint: ".",
             radixPoint: ".",
             groupSize: 3,
             groupSize: 3,
             autoGroup: false,
             autoGroup: false,
@@ -35,11 +35,13 @@ Optional extensions on the jquery.inputmask base
                 return calculatedLength + groupOffset;
                 return calculatedLength + groupOffset;
             },
             },
             postFormat: function (buffer, pos, reformatOnly, opts) {
             postFormat: function (buffer, pos, reformatOnly, opts) {
+                if (opts.groupSeparator == "") return pos;
                 var cbuf = buffer.slice();
                 var cbuf = buffer.slice();
                 if (!reformatOnly) cbuf.splice(pos, 0, "?"); //set position indicator
                 if (!reformatOnly) cbuf.splice(pos, 0, "?"); //set position indicator
                 var bufVal = cbuf.join('');
                 var bufVal = cbuf.join('');
                 if (opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
                 if (opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
-                    bufVal = bufVal.replace(new RegExp("\\" + opts.groupSeparator, "g"), '');
+                    var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
+                    bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), '');
                     var radixSplit = bufVal.split(opts.radixPoint);
                     var radixSplit = bufVal.split(opts.radixPoint);
                     bufVal = radixSplit[0];
                     bufVal = radixSplit[0];
                     var reg = new RegExp('([-\+]?[\\d\?]+)([\\d\?]{' + opts.groupSize + '})');
                     var reg = new RegExp('([-\+]?[\\d\?]+)([\\d\?]{' + opts.groupSize + '})');
@@ -97,8 +99,10 @@ Optional extensions on the jquery.inputmask base
 
 
                         cbuf.splice(pos + 1, 0, chrs);
                         cbuf.splice(pos + 1, 0, chrs);
                         var bufferStr = cbuf.join('');
                         var bufferStr = cbuf.join('');
-                        if (opts.autoGroup && !strict) //strip groupseparator
-                            bufferStr = bufferStr.replace(new RegExp("\\" + opts.groupSeparator, "g"), '');
+                        if (opts.autoGroup && !strict) { //strip groupseparator
+                            var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
+                            bufferStr = bufferStr.replace(new RegExp(escapedGroupSeparator, "g"), '');
+                        }
                         var isValid = opts.regex.number(opts.groupSeparator, opts.groupSize, opts.radixPoint, opts.digits).test(bufferStr);
                         var isValid = opts.regex.number(opts.groupSeparator, opts.groupSize, opts.radixPoint, opts.digits).test(bufferStr);
                         if (!isValid) {
                         if (!isValid) {
                             //let's help the regex a bit
                             //let's help the regex a bit
@@ -157,6 +161,15 @@ Optional extensions on the jquery.inputmask base
                 }
                 }
             },
             },
             alias: "decimal"
             alias: "decimal"
+        },
+        'non-negative-integer': {
+            regex: {
+                number: function (groupSeparator, groupSize) {
+                    var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, groupSeparator);
+                    return new RegExp("^[\+]?(\\d+|\\d{1," + groupSize + "}((" + escapedGroupSeparator + "\\d{" + groupSize + "})?)+)$");
+                }
+            },
+            alias: "integer"
         }
         }
     });
     });
 })(jQuery);
 })(jQuery);