浏览代码

some fixes for the numeric alias

Robin Herbots 11 年之前
父节点
当前提交
5d6640d70a

+ 9 - 3
dist/inputmask/jquery.inputmask.js

@@ -233,7 +233,7 @@
                 (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx), 
                 psNdx >= closestTo && (after = psNdx));
             }
-            return lastValidPosition = closestTo - before > 1 || closestTo > after ? before : after;
+            return lastValidPosition = -1 != before && closestTo - before > 1 || closestTo > after ? before : after;
         }
         function setValidPosition(pos, validTest, fromSetValid) {
             if (opts.insertMode && void 0 != getMaskSet().validPositions[pos] && void 0 == fromSetValid) {
@@ -554,7 +554,7 @@
         function checkVal(input, writeOut, strict, nptvl) {
             function isTemplateMatch() {
                 var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
-                if (-1 != charCodeNdx) {
+                if (-1 != charCodeNdx && !isMask(initialNdx)) {
                     isMatch = !0;
                     for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " != bufferTemplateArr[i]) {
                         isMatch = !1;
@@ -569,6 +569,7 @@
             matches && matches.length > 0 && inputValue.splice(0, staticInput.length * matches.length);
             var charCodes = "", initialNdx = 0;
             $.each(inputValue, function(ndx, charCode) {
+                console.log("checkval " + charCode);
                 var keypress = $.Event("keypress");
                 keypress.which = charCode.charCodeAt(0), charCodes += charCode;
                 var lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
@@ -860,7 +861,12 @@
         function pasteEvent(e) {
             var input = this, $input = $(input), inputValue = input._valueGet(!0), caretPos = caret(input);
             if ("propertychange" == e.type && input._valueGet().length <= getMaskLength()) return !0;
-            "paste" == e.type && (window.clipboardData && window.clipboardData.getData ? inputValue = inputValue.substr(0, caretPos.begin) + window.clipboardData.getData("Text") + inputValue.substr(caretPos.end, inputValue.length) : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = inputValue.substr(0, caretPos.begin) + e.originalEvent.clipboardData.getData("text/plain") + inputValue.substr(caretPos.end, inputValue.length)));
+            if ("paste" == e.type) {
+                var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
+                valueBeforeCaret == getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""), 
+                valueAfterCaret == getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""), 
+                window.clipboardData && window.clipboardData.getData ? inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = valueBeforeCaret + e.originalEvent.clipboardData.getData("text/plain") + valueAfterCaret);
+            }
             var pasteValue = $.isFunction(opts.onBeforePaste) ? opts.onBeforePaste.call(input, inputValue, opts) || inputValue : inputValue;
             return checkVal(input, !0, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.split("")), 
             $input.click(), isComplete(getBuffer()) === !0 && $input.trigger("complete"), !1;

+ 9 - 11
dist/inputmask/jquery.inputmask.numeric.extensions.js

@@ -73,7 +73,7 @@
             onBeforeWrite: function(e, buffer, caretPos, opts) {
                 if (e && "blur" == e.type) {
                     var tmpBufSplit = "" != opts.radixPoint ? buffer.join("").split(opts.radixPoint) : [ buffer.join("") ], matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)), matchRsltDigits = 2 == tmpBufSplit.length ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : void 0;
-                    matchRslt && "-0" == matchRslt[matchRslt.index] && (void 0 == matchRsltDigits || matchRsltDigits[matchRsltDigits.index].match(/^0+$/)) && buffer.splice(0, 1);
+                    matchRslt && "-0" == matchRslt[0] && (void 0 == matchRsltDigits || matchRsltDigits[0].match(/^0+$/)) && buffer.splice(0, 1);
                     var radixPosition = $.inArray(opts.radixPoint, buffer);
                     if (-1 != radixPosition && isFinite(opts.digits) && !opts.digitsOptional) {
                         for (var i = 1; i <= opts.digits; i++) (void 0 == buffer[radixPosition + i] || buffer[radixPosition + i] == opts.placeholder.charAt(0)) && (buffer[radixPosition + i] = "0");
@@ -99,7 +99,7 @@
             signHandler: function(chrs, maskset, pos, strict, opts) {
                 if (!strict && (opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs)) {
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
-                    if (matchRslt && matchRslt[matchRslt.index].length > 0 && ("0" !== matchRslt[matchRslt.index] || maskset.buffer && maskset._buffer && maskset.buffer.join("") != maskset._buffer.join(""))) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
+                    if (matchRslt && matchRslt[0].length > 0 && ("0" !== matchRslt[0] || maskset.buffer && maskset._buffer && maskset.buffer.join("") != maskset._buffer.join(""))) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
                         pos: matchRslt.index,
                         c: chrs,
                         remove: matchRslt.index,
@@ -134,22 +134,20 @@
             },
             leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
                 var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if ("0" == matchRslt[0] && pos >= opts.prefix.length) {
-                    if (-1 == radixPosition || radixPosition >= pos && void 0 == maskset.validPositions[radixPosition]) return maskset.buffer.splice(matchRslt.index, 1), 
+                if (matchRslt && !strict && (-1 == radixPosition || radixPosition >= pos) && 0 == matchRslt[0].indexOf("0")) {
+                    pos < opts.prefix.length && (pos = matchRslt.index);
+                    var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, radixPosition).join("");
+                    if (-1 == radixPosition || digitsMatch && integerMatch) return maskset.buffer.splice(matchRslt.index, 1), 
                     pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
                         pos: pos,
                         remove: matchRslt.index
                     };
-                    if (pos >= matchRslt.index && radixPosition >= pos) return maskset.buffer.splice(matchRslt.index, 1), 
-                    pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
+                    if (matchRslt.index + 1 == pos || "0" == chrs) return maskset.buffer.splice(matchRslt.index, 1), 
+                    pos = matchRslt.index, {
                         pos: pos,
                         remove: matchRslt.index
                     };
-                    if (void 0 == maskset.validPositions[radixPosition]) return maskset.buffer[pos] = chrs, 
-                    {
-                        refreshFromBuffer: !0
-                    };
-                } else if ("0" == chrs && pos <= matchRslt.index) return !1;
+                }
                 return !0;
             },
             definitions: {

+ 18 - 14
dist/jquery.inputmask.bundle.js

@@ -231,7 +231,7 @@
                 (-1 == closestTo || null != valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx), 
                 psNdx >= closestTo && (after = psNdx));
             }
-            return lastValidPosition = closestTo - before > 1 || closestTo > after ? before : after;
+            return lastValidPosition = -1 != before && closestTo - before > 1 || closestTo > after ? before : after;
         }
         function setValidPosition(pos, validTest, fromSetValid) {
             if (opts.insertMode && void 0 != getMaskSet().validPositions[pos] && void 0 == fromSetValid) {
@@ -552,7 +552,7 @@
         function checkVal(input, writeOut, strict, nptvl) {
             function isTemplateMatch() {
                 var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
-                if (-1 != charCodeNdx) {
+                if (-1 != charCodeNdx && !isMask(initialNdx)) {
                     isMatch = !0;
                     for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " != bufferTemplateArr[i]) {
                         isMatch = !1;
@@ -567,6 +567,7 @@
             matches && matches.length > 0 && inputValue.splice(0, staticInput.length * matches.length);
             var charCodes = "", initialNdx = 0;
             $.each(inputValue, function(ndx, charCode) {
+                console.log("checkval " + charCode);
                 var keypress = $.Event("keypress");
                 keypress.which = charCode.charCodeAt(0), charCodes += charCode;
                 var lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
@@ -858,7 +859,12 @@
         function pasteEvent(e) {
             var input = this, $input = $(input), inputValue = input._valueGet(!0), caretPos = caret(input);
             if ("propertychange" == e.type && input._valueGet().length <= getMaskLength()) return !0;
-            "paste" == e.type && (window.clipboardData && window.clipboardData.getData ? inputValue = inputValue.substr(0, caretPos.begin) + window.clipboardData.getData("Text") + inputValue.substr(caretPos.end, inputValue.length) : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = inputValue.substr(0, caretPos.begin) + e.originalEvent.clipboardData.getData("text/plain") + inputValue.substr(caretPos.end, inputValue.length)));
+            if ("paste" == e.type) {
+                var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
+                valueBeforeCaret == getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""), 
+                valueAfterCaret == getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""), 
+                window.clipboardData && window.clipboardData.getData ? inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret : e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData && (inputValue = valueBeforeCaret + e.originalEvent.clipboardData.getData("text/plain") + valueAfterCaret);
+            }
             var pasteValue = $.isFunction(opts.onBeforePaste) ? opts.onBeforePaste.call(input, inputValue, opts) || inputValue : inputValue;
             return checkVal(input, !0, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.split("")), 
             $input.click(), isComplete(getBuffer()) === !0 && $input.trigger("complete"), !1;
@@ -1879,7 +1885,7 @@
             onBeforeWrite: function(e, buffer, caretPos, opts) {
                 if (e && "blur" == e.type) {
                     var tmpBufSplit = "" != opts.radixPoint ? buffer.join("").split(opts.radixPoint) : [ buffer.join("") ], matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)), matchRsltDigits = 2 == tmpBufSplit.length ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : void 0;
-                    matchRslt && "-0" == matchRslt[matchRslt.index] && (void 0 == matchRsltDigits || matchRsltDigits[matchRsltDigits.index].match(/^0+$/)) && buffer.splice(0, 1);
+                    matchRslt && "-0" == matchRslt[0] && (void 0 == matchRsltDigits || matchRsltDigits[0].match(/^0+$/)) && buffer.splice(0, 1);
                     var radixPosition = $.inArray(opts.radixPoint, buffer);
                     if (-1 != radixPosition && isFinite(opts.digits) && !opts.digitsOptional) {
                         for (var i = 1; i <= opts.digits; i++) (void 0 == buffer[radixPosition + i] || buffer[radixPosition + i] == opts.placeholder.charAt(0)) && (buffer[radixPosition + i] = "0");
@@ -1905,7 +1911,7 @@
             signHandler: function(chrs, maskset, pos, strict, opts) {
                 if (!strict && (opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs)) {
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
-                    if (matchRslt && matchRslt[matchRslt.index].length > 0 && ("0" !== matchRslt[matchRslt.index] || maskset.buffer && maskset._buffer && maskset.buffer.join("") != maskset._buffer.join(""))) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
+                    if (matchRslt && matchRslt[0].length > 0 && ("0" !== matchRslt[0] || maskset.buffer && maskset._buffer && maskset.buffer.join("") != maskset._buffer.join(""))) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
                         pos: matchRslt.index,
                         c: chrs,
                         remove: matchRslt.index,
@@ -1940,22 +1946,20 @@
             },
             leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
                 var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                if (matchRslt && !strict && (-1 == radixPosition || matchRslt.index < radixPosition)) if ("0" == matchRslt[0] && pos >= opts.prefix.length) {
-                    if (-1 == radixPosition || radixPosition >= pos && void 0 == maskset.validPositions[radixPosition]) return maskset.buffer.splice(matchRslt.index, 1), 
+                if (matchRslt && !strict && (-1 == radixPosition || radixPosition >= pos) && 0 == matchRslt[0].indexOf("0")) {
+                    pos < opts.prefix.length && (pos = matchRslt.index);
+                    var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") == maskset._buffer.slice(radixPosition).join(""), integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join("") == maskset._buffer.slice(opts.prefix.length, radixPosition).join("");
+                    if (-1 == radixPosition || digitsMatch && integerMatch) return maskset.buffer.splice(matchRslt.index, 1), 
                     pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
                         pos: pos,
                         remove: matchRslt.index
                     };
-                    if (pos >= matchRslt.index && radixPosition >= pos) return maskset.buffer.splice(matchRslt.index, 1), 
-                    pos = pos > matchRslt.index ? pos - 1 : matchRslt.index, {
+                    if (matchRslt.index + 1 == pos || "0" == chrs) return maskset.buffer.splice(matchRslt.index, 1), 
+                    pos = matchRslt.index, {
                         pos: pos,
                         remove: matchRslt.index
                     };
-                    if (void 0 == maskset.validPositions[radixPosition]) return maskset.buffer[pos] = chrs, 
-                    {
-                        refreshFromBuffer: !0
-                    };
-                } else if ("0" == chrs && pos <= matchRslt.index) return !1;
+                }
                 return !0;
             },
             definitions: {

文件差异内容过多而无法显示
+ 2 - 2
dist/jquery.inputmask.bundle.min.js


+ 11 - 4
js/jquery.inputmask.js

@@ -397,7 +397,7 @@
                         if (psNdx >= closestTo) after = psNdx;
                     }
                 }
-                lastValidPosition = (closestTo - before) > 1 || after < closestTo ? before : after;
+                lastValidPosition = (before != -1 && (closestTo - before) > 1) || after < closestTo ? before : after;
                 return lastValidPosition;
             }
             function setValidPosition(pos, validTest, fromSetValid) {
@@ -994,7 +994,7 @@
                 function isTemplateMatch() {
                     var isMatch = false;
                     var charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join('').indexOf(charCodes);
-                    if (charCodeNdx != -1) {
+                    if (charCodeNdx != -1 && !isMask(initialNdx)) {
                         isMatch = true;
                         var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx);
                         for (var i = 0; i < bufferTemplateArr.length; i++) {
@@ -1018,6 +1018,7 @@
 
                 var charCodes = "", initialNdx = 0;
                 $.each(inputValue, function (ndx, charCode) {
+                    console.log("checkval " + charCode);
                     var keypress = $.Event("keypress");
                     keypress.which = charCode.charCodeAt(0);
                     charCodes += charCode;
@@ -1539,10 +1540,16 @@
                 if (e.type == "propertychange" && input._valueGet().length <= getMaskLength()) {
                     return true;
                 } else if (e.type == "paste") {
+                    var valueBeforeCaret = inputValue.substr(0, caretPos.begin),
+                        valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
+
+                    if (valueBeforeCaret == getBufferTemplate().slice(0, caretPos.begin).join('')) valueBeforeCaret = "";
+                    if (valueAfterCaret == getBufferTemplate().slice(caretPos.end).join('')) valueAfterCaret = "";
+
                     if (window.clipboardData && window.clipboardData.getData) { // IE
-                        inputValue = inputValue.substr(0, caretPos.begin) + window.clipboardData.getData('Text') + inputValue.substr(caretPos.end, inputValue.length);
+                        inputValue = valueBeforeCaret + window.clipboardData.getData('Text') + valueAfterCaret;
                     } else if (e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) {
-                        inputValue = inputValue.substr(0, caretPos.begin) + e.originalEvent.clipboardData.getData('text/plain') + inputValue.substr(caretPos.end, inputValue.length);;
+                        inputValue = valueBeforeCaret + e.originalEvent.clipboardData.getData('text/plain') + valueAfterCaret;
                     }
                 }
 

+ 11 - 12
js/jquery.inputmask.numeric.extensions.js

@@ -119,7 +119,7 @@ Optional extensions on the jquery.inputmask base
                     var tmpBufSplit = opts.radixPoint != "" ? buffer.join('').split(opts.radixPoint) : [buffer.join('')],
                    matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)),
                    matchRsltDigits = tmpBufSplit.length == 2 ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : undefined;
-                    if (matchRslt && matchRslt[matchRslt.index] == "-0" && (matchRsltDigits == undefined || matchRsltDigits[matchRsltDigits.index].match(/^0+$/))) {
+                    if (matchRslt && matchRslt[0] == "-0" && (matchRsltDigits == undefined || matchRsltDigits[0].match(/^0+$/))) {
                         buffer.splice(0, 1);
                     }
                     var radixPosition = $.inArray(opts.radixPoint, buffer);
@@ -145,7 +145,7 @@ Optional extensions on the jquery.inputmask base
                 if (!strict && (opts.allowMinus && chrs === "-" || opts.allowPlus && chrs === "+")) {
                     var matchRslt = maskset.buffer.join('').match(opts.regex.integerPart(opts));
 
-                    if (matchRslt && matchRslt[matchRslt.index].length > 0 && (matchRslt[matchRslt.index] !== "0" || (maskset.buffer && maskset._buffer && maskset.buffer.join('') != maskset._buffer.join('')))) {
+                    if (matchRslt && matchRslt[0].length > 0 && (matchRslt[0] !== "0" || (maskset.buffer && maskset._buffer && maskset.buffer.join('') != maskset._buffer.join('')))) {
                         if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "+" : "-")) {
                             return { "pos": matchRslt.index, "c": chrs, "remove": matchRslt.index, "caret": pos };
                         } else if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "-" : "+")) {
@@ -174,22 +174,21 @@ Optional extensions on the jquery.inputmask base
             },
             leadingZeroHandler: function (chrs, maskset, pos, strict, opts) {
                 var matchRslt = maskset.buffer.join('').match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                if (matchRslt && !strict && (radixPosition == -1 || matchRslt.index < radixPosition)) {
-                    if (matchRslt["0"] == "0" && pos >= opts.prefix.length) {
-                        if (radixPosition == -1 || (pos <= radixPosition && maskset["validPositions"][radixPosition] == undefined)) {
+                if (matchRslt && !strict && (radixPosition == -1 || pos <= radixPosition)) {
+                    if (matchRslt["0"].indexOf("0") == 0) {
+                        if (pos < opts.prefix.length) pos = matchRslt.index; //position
+                        var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join('') == maskset._buffer.slice(radixPosition).join('');
+                        var integerMatch = maskset._buffer && maskset.buffer.slice(opts.prefix.length, radixPosition).join('') == maskset._buffer.slice(opts.prefix.length, radixPosition).join('');
+
+                        if (radixPosition == -1 || digitsMatch && integerMatch) {
                             maskset.buffer.splice(matchRslt.index, 1);
                             pos = pos > matchRslt.index ? pos - 1 : matchRslt.index;
                             return { "pos": pos, "remove": matchRslt.index };
-                        } else if (pos >= matchRslt.index && pos <= radixPosition) {
+                        } else if (matchRslt.index + 1 == pos || chrs == "0") {
                             maskset.buffer.splice(matchRslt.index, 1);
-                            pos = pos > matchRslt.index ? pos - 1 : matchRslt.index;
+                            pos = matchRslt.index;
                             return { "pos": pos, "remove": matchRslt.index };
-                        } if (maskset["validPositions"][radixPosition] == undefined) {
-                            maskset["buffer"][pos] = chrs;
-                            return { "refreshFromBuffer": true };
                         }
-                    } else if (chrs == "0" && pos <= matchRslt.index) {
-                        return false;
                     }
                 }
                 return true;

+ 56 - 0
qunit/tests_paste.js

@@ -149,4 +149,60 @@ asyncTest("currency ~ $123.22 - sjk07", function () {
         start();
         $("#testmask").remove();
     }, 0);
+});
+
+asyncTest("currency ~ $-123.22 - sjk07", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask('currency');
+    $("#testmask")[0].focus();
+    $("#testmask").paste("$-123.22");
+
+    setTimeout(function () {
+        equal($("#testmask").val(), "$ -123.22", "Result " + $("#testmask").val());
+        start();
+        $("#testmask").remove();
+    }, 0);
+});
+
+asyncTest("currency ~ 1000.00 - sjk07", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask('currency');
+    $("#testmask")[0].focus();
+    $("#testmask").paste("1000.00");
+
+    setTimeout(function () {
+        equal($("#testmask").val(), "$ 1,000.00", "Result " + $("#testmask").val());
+        start();
+        $("#testmask").remove();
+    }, 0);
+});
+
+asyncTest("currency ~ -1000.00 - sjk07", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask('currency');
+    $("#testmask")[0].focus();
+    $("#testmask").paste("-1000.00");
+
+    setTimeout(function () {
+        equal($("#testmask").val(), "$ -1,000.00", "Result " + $("#testmask").val());
+        start();
+        $("#testmask").remove();
+    }, 0);
+});
+
+asyncTest("currency ~ 000.02 - sjk07", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask('currency');
+    $("#testmask")[0].focus();
+    $("#testmask").paste("000.02");
+
+    setTimeout(function () {
+        equal($("#testmask").val(), "$ 0.02", "Result " + $("#testmask").val());
+        start();
+        $("#testmask").remove();
+    }, 0);
 });