ソースを参照

Numeric aliases insert '0' in input after clearing if there was fraction part fix #1067

Robin Herbots 10 年 前
コミット
58da2f3d6e
2 ファイル変更17 行追加9 行削除
  1. 1 0
      CHANGELOG.md
  2. 16 9
      js/inputmask.numeric.extensions.js

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
 ### Updates
 
 ### Fixed
+- Numeric aliases insert '0' in input after clearing if there was fraction part #1067
 - Clear optional tail in getvalue. See #1055 #1065
 
 ## [3.2.2] - 2015-09-04

+ 16 - 9
js/inputmask.numeric.extensions.js

@@ -669,15 +669,22 @@ Optional extensions on the jquery.inputmask base
 						if (radixPos > 0) {
 							var bufVal = buffer.join("");
 							matchRslt = bufVal.match(opts.regex.integerNPart(opts));
-							if (matchRslt && position <= radixPos) {
-								if (matchRslt["0"].indexOf("0") === 0) {
-									canClear = matchRslt.index !== position || opts.placeholder === "0";
-								} else {
-									var intPart = parseInt(matchRslt["0"].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")),
-										radixPart = parseInt(bufVal.split(opts.radixPoint)[1]);
-									if (intPart < 10 && maskset.validPositions[position] && (opts.placeholder !== "0" || radixPart > 0)) {
-										maskset.validPositions[position].input = "0";
-										maskset.p = opts.prefix.length + 1;
+							if (matchRslt) {
+								if (position <= radixPos) {
+									if (matchRslt["0"].indexOf("0") === 0) {
+										canClear = matchRslt.index !== position || opts.placeholder === "0";
+									} else {
+										var intPart = parseInt(matchRslt["0"].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")),
+											radixPart = parseInt(bufVal.split(opts.radixPoint)[1]);
+										if (intPart < 10 && maskset.validPositions[position] && (opts.placeholder !== "0" || radixPart > 0)) {
+											maskset.validPositions[position].input = "0";
+											maskset.p = opts.prefix.length + 1;
+											canClear = false;
+										}
+									}
+								} else if (matchRslt["0"].indexOf("0") === 0) {
+									if (bufVal.length === 3) {
+										maskset.validPositions = {};
 										canClear = false;
 									}
 								}