javascript - jquery.inputmask - set value in "oncomplete" callback makes incorrect action - Stack Overflow

If in "onplete" callback make setVal action with other masked input, you can see incorrect re

If in "onplete" callback make setVal action with other masked input, you can see incorrect reactions in Chrome and Safary, well work in FF

onplete: function(e){
    $('.i-input-2').val($(e.currentTarget).inputmask('unmaskedvalue'));
}

Demo: /

If in "onplete" callback make setVal action with other masked input, you can see incorrect reactions in Chrome and Safary, well work in FF

onplete: function(e){
    $('.i-input-2').val($(e.currentTarget).inputmask('unmaskedvalue'));
}

Demo: http://jsfiddle/serGlazkov/nxLzq82o/

Share Improve this question edited Sep 25, 2015 at 22:19 Joshua Dannemann 2,0802 gold badges16 silver badges35 bronze badges asked Sep 18, 2015 at 0:35 sglazkovsglazkov 1,0661 gold badge10 silver badges38 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7 +50

It seems as though you have uncovered a critical bug with the jQuery inputmask plugin. There is some aggressive caret position handling when using autoGroup and digitsOptional options. When bined with multiple masked input instances it causes the caret to moved to index 0 after every keystroke.

Using the currency mask with the following options will give you the most consistent interface.

$('.i-input-1').inputmask({
    alias: 'currency',
    rightAlign: false,
    digits: 2,
    onplete: function (e) {
        var currVal = $(e.currentTarget).inputmask('unmaskedvalue');
        copyValue1(currVal);
    }
});

$('.i-input-2').inputmask({
    alias: 'currency',
    rightAlign: false,
    digits: 2
});

function copyValue1(str){
    $('.i-input-2').val(str);
}
<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://dev.vanare/bundles/vanarewebsite/js/jquery.inputmask.bundle.min.js"></script>
<input type="text" class="i-input-1" value="100">
<input type="text" class="i-input-2" value="555" disabled="disabled">

Now this bug fixed in version 3.2.2

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742411333a4438872.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信