ソースを参照

fix value formatting #469

Robin Herbots 11 年 前
コミット
cdbf5a623a
2 ファイル変更10 行追加5 行削除
  1. 5 5
      js/jquery.inputmask.js
  2. 5 0
      qunit/tests.js

+ 5 - 5
js/jquery.inputmask.js

@@ -1248,9 +1248,9 @@
                             opts.isNumeric = opts.numericInput;
                             isRTL = true;
                         }
-
-                        checkVal($el, false, false, actionObj["value"].split(''), true);
-                        return getBuffer().join('');
+						var valueBuffer = actionObj["value"].split('');
+                        checkVal($el, false, false, isRTL ? valueBuffer.reverse() : valueBuffer, true);
+                        return isRTL ? getBuffer().reverse().join('') : getBuffer().join('');
                     case "isValid":
                         $el = $({});
                         $el.data('_inputmask', {
@@ -1262,8 +1262,8 @@
                             opts.isNumeric = opts.numericInput;
                             isRTL = true;
                         }
-
-                        checkVal($el, false, true, actionObj["value"].split(''));
+						var valueBuffer = actionObj["value"].split('');
+                        checkVal($el, false, true, isRTL ? valueBuffer.reverse() : valueBuffer);
                         return isComplete(getBuffer());
                 }
             }

+ 5 - 0
qunit/tests.js

@@ -2117,6 +2117,11 @@ test("$.inputmask.format(\"016501030020001DE1015170\", { mask: \"99 999 999 999
     equal(formattedValue, "01 650 103 002 0001 DE101 5170", "Result " + formattedValue);
 });
 
+test("$.inputmask.format(\"12\", {  mask: \"$ 999999\", numericInput: true, placeholder: \"0\" }); - gigermocas", function () {
+    var formattedValue = $.inputmask.format("12", {  mask: "$ 999999", numericInput: true, placeholder: "0" });
+    equal(formattedValue, "$ 000012", "Result " + formattedValue);
+});
+
 module("Value Validating");
 test("$.inputmask.isValid(\"23/03/1973\", { alias: \"date\"})", function () {
     var formattedValue = $.inputmask.isValid("23/03/1973", { alias: "date" });