Browse Source

Cleanup Numeric support + update readme

Robin Herbots 13 years ago
parent
commit
1277627461
3 changed files with 25 additions and 23 deletions
  1. 16 1
      README.md
  2. 3 7
      js/jquery.inputmask.js
  3. 6 15
      js/jquery.inputmask.numeric.extensions.js

+ 16 - 1
README.md

@@ -336,10 +336,25 @@ $(document).ready(function(){
 });
 ```
 
-Autocompletion on tab with decimal numbers
+There is autocompletion on tab with decimal numbers.
+
+Define the radixpoint
+
+```javascript
+$(document).ready(function(){
+   $("#numeric").inputmask("decimal" { radixPoint: "," });
+});
+```
+Define the number of digits after the radixpoint
 
 ```javascript
 $(document).ready(function(){
    $("#numeric").inputmask("decimal" { digits: 3 });
 });
 ```
+Grouping support through:  autoGroup, groupSeparator, groupSize
+```javascript
+$(document).ready(function(){
+   $("#numeric").inputmask("decimal" { radixPoint: ",", autoGroup: true, groupSeparator: ".", groupSize: 3 });
+});
+```

+ 3 - 7
js/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2012 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 1.0.18c
+* Version: 1.0.19
 */
 
 (function ($) {
@@ -32,14 +32,10 @@
                 aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
                 onKeyUp: $.noop, //override to implement autocomplete on certain keys for example
                 onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
-                //numeric properties
+                //numeric basic properties
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                 radixPoint: ".", // | ","
-                digits: "*", //numer of digits
-                groupSeparator: ",", // | "."
-                groupSize: 3,
-                autoGroup: false,
-                //numeric properties
+                //numeric basic properties
                 definitions: {
                     '9': {
                         validator: "[0-9]",

+ 6 - 15
js/jquery.inputmask.numeric.extensions.js

@@ -3,25 +3,12 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 1.0.10.d
+Version: 1.0.19
 
 Optional extensions on the jquery.inputmask base
 */
 (function ($) {
     //number aliases
-    //$.extend($.inputmask.defaults.definitions, {
-    //    '9': {
-    //        validator: function(chrs, buffer, pos, strict, opts) {
-    //            var isValid = opts.definitions['9'].regex.test(chrs);
-    //            if (isValid) {
-    //do some grouping
-    //            }
-    //            return isValid;
-    //        },
-    //        cardinality: 1,
-    //        regex: new RegExp("[0-9]")
-    //    }
-    //});
     $.extend($.inputmask.defaults.aliases, {
         'decimal': {
             mask: "~",
@@ -29,6 +16,10 @@ Optional extensions on the jquery.inputmask base
             repeat: 10,
             greedy: false,
             numericInput: true,
+			digits: "*", //numer of digits
+            groupSeparator: ",", // | "."
+            groupSize: 3,
+            autoGroup: false,
             regex: {
                 number: function (groupSeparator, groupSize, radixPoint, digits) {
                     return new RegExp("^[\+\\d\-]{1}[\\d" + groupSeparator + "]*[" + radixPoint + "]?\\d" + digits + "$");
@@ -85,7 +76,7 @@ Optional extensions on the jquery.inputmask base
                         if (opts.autoGroup && isValid != false && !strict) {
                             var bufVal = buffer.join('') + chrs;
                             bufVal = bufVal.replace(new RegExp("\\" + opts.groupSeparator, "g"), '');
-                            var reg = new RegExp('(-?[0-9]+)([0-9]{3})');
+                            var reg = new RegExp('(-?[0-9]+)([0-9]{' + opts.groupSize + '})');
                             while (reg.test(bufVal)) {
                                 bufVal = bufVal.replace(reg, '$1' + opts.groupSeparator + '$2');
                             }