最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论