user8346578 user8346578 - 3 years ago 219
jQuery Question

JQuery Inputmask on tab onfocus caret shifting

I am attempting to use the JQuery library Inputmask by robin herbots. It appears to have a feature that the last known caret of a text box is stored and used when you tab into a textbox it sets the caret to that position. I do not desire this feature. I wish to have the default feature where when you tab into a textbox the entire text is selected. I have tried setting the onfocus event of the input to this.select() but it appears that the library overrides or shifts the caret after that event fires.

Below are some of the options I have tried using. I would have guessed that the positionCaretOnTab would have done exactly what I want based on the ReadMe file but it doesnt appear to have any effect.

$input.inputmask({
alias: 'currency',
integerDigits: 12,
digits: 2,
autoGroup: true,
groupSeparator: ',',
autoUnmask: true,
positionCaretOnTab: false,
numericInput: false,
positionCaretOnClick: "none"
});

Answer Source

I think that your code is working isnt?

$("#example2").inputmask({
                            alias: 'currency',
                            integerDigits: 12,
                            digits: 2,
                            autoGroup: true,
                            groupSeparator: ',',
                            autoUnmask: true,
                            positionCaretOnTab: false,
                            numericInput: false,
                            positionCaretOnClick: "none"
                        }); 
<script src="https://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="https://rawgit.com/RobinHerbots/Inputmask/4.x/dist/jquery.inputmask.bundle.js"></script>

<input type="text"  id="example1"/>
<input type="text"  id="example2"/>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download