Ich habe eine autotab Funktion,autotabulate andernfalls mit IE
<input type="text" class="autoTab" maxlength="2" /> :
<input type="text" />
autoTab : function(){
$('.autoTab').on('keypress', function(e){
if($(this).val().length + 1 === parseInt($(this).attr("maxlength"))){
$(this).next().focus();
}
});
}
es funktioniert gut in Chrome, aber in IE, tabellarisch vor Schreib de letzte Zeichen, und es wird nicht geschrieben.
Ich versuchte dies:
autoTab : function(){
$('.autoTab').on('keypress', function(e){
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
var isIE = (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./));
if((!isIE && $(this).val().length + 1 === parseInt($(this).attr("maxlength"))) || (isIE && $(this).val().length === parseInt($(this).attr("maxlength")))) {
$(this).next().focus();
}
});
}
es funktioniert immer noch in Chrome, aber in IE, ich schreibe 2 Zeichen und der Cursor weiter in der Box.
Wie kann ich es beheben?