ソースを参照

fix for issue 154 decimal mask for 2.x branch

Robin Herbots 13 年 前
コミット
6f0e6c2798
1 ファイル変更6 行追加8 行削除
  1. 6 8
      js/jquery.inputmask.js

+ 6 - 8
js/jquery.inputmask.js

@@ -3,12 +3,11 @@
 * 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.0.6
+* Version: 2.0.7
 */
 */
 
 
 (function ($) {
 (function ($) {
-    if ($.fn.inputmask == undefined) {
-        $.inputmask = {
+    if ($.fn.inputmask == undefined) {        $.inputmask = {
             //options default
             //options default
             defaults: {
             defaults: {
                 placeholder: "_",
                 placeholder: "_",
@@ -35,7 +34,7 @@
                 //numeric basic properties
                 //numeric basic properties
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                 numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                 radixPoint: ".", // | ","
                 radixPoint: ".", // | ","
-                //numeric basic properties
+               //numeric basic properties
                 definitions: {
                 definitions: {
                     '9': {
                     '9': {
                         validator: "[0-9]",
                         validator: "[0-9]",
@@ -333,9 +332,8 @@
 
 
                         maskPos = isRTL ? seekPrevious(buffer, pos) : seekNext(buffer, pos);
                         maskPos = isRTL ? seekPrevious(buffer, pos) : seekNext(buffer, pos);
                     }
                     }
-
-                    if (isRTL ? activeMaskset['lastValidPosition'] <= seekNext(buffer, maskPos) : activeMaskset['lastValidPosition'] >= seekPrevious(buffer, maskPos)) {
-                        if (maskPos >= 0 && maskPos < getMaskLength()) {
+					if (isRTL ? activeMaskset['lastValidPosition'] <= opts.numericInput ? getMaskLength() : seekNext(buffer, maskPos) : activeMaskset['lastValidPosition'] >= seekPrevious(buffer, maskPos)) {
+                      if (maskPos >= 0 && maskPos < getMaskLength()) {
                             var testPos = determineTestPosition(maskPos), loopend = c ? 1 : 0, chrs = '';
                             var testPos = determineTestPosition(maskPos), loopend = c ? 1 : 0, chrs = '';
                             for (var i = activeMaskset['tests'][testPos].cardinality; i > loopend; i--) {
                             for (var i = activeMaskset['tests'][testPos].cardinality; i > loopend; i--) {
                                 chrs += getBufferElement(buffer, testPos - (i - 1));
                                 chrs += getBufferElement(buffer, testPos - (i - 1));
@@ -1082,7 +1080,7 @@
                     e = e || window.event;
                     e = e || window.event;
                     var k = e.which || e.charCode || e.keyCode;
                     var k = e.which || e.charCode || e.keyCode;
 
 
-                    if (opts.numericInput && k == opts.radixPoint.charCodeAt(opts.radixPoint.length - 1)) {
+                    if (opts.numericInput && k == opts.radixPoint) {
                         var nptStr = input._valueGet();
                         var nptStr = input._valueGet();
                         var radixPosition = nptStr.indexOf(opts.radixPoint);
                         var radixPosition = nptStr.indexOf(opts.radixPoint);
                         caret(input, seekNext(buffer, radixPosition != -1 ? radixPosition : getMaskLength()));
                         caret(input, seekNext(buffer, radixPosition != -1 ? radixPosition : getMaskLength()));