3

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

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

Demo: http://jsfiddle.net/serGlazkov/nxLzq82o/

Joshua Dannemann
  • 2,003
  • 1
  • 14
  • 34
sglazkov
  • 1,046
  • 1
  • 10
  • 38

2 Answers2

7

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 combined 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,
    oncomplete: 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.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://dev.vanare.net/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">
ffffranklin
  • 329
  • 1
  • 2
1

Now this bug fixed in version 3.2.2

sglazkov
  • 1,046
  • 1
  • 10
  • 38