3
I have a function with Jquery that leaves the text of the textbox in uppercase, the problem is that when I have a mask in the field, after typing any character, the cursor goes to the end of the textbox, then the user has to go back and type again, and the cursor goes back to the end, this only happens in fields with mask, follows the function.
jQuery(document).ready(function ($) {
// Chamada da funcao upperText(); ao carregar a pagina
upperText();
// Funcao que faz o texto ficar em uppercase
function upperText() {
// Para tratar o colar
$(":input").bind('paste', function (e) {
var el = $(this);
setTimeout(function () {
var text = $(el).val();
el.val(text.toUpperCase());
}, 100);
});
// Para tratar quando é digitado
$(":input").keypress(function () {
var el = $(this);
setTimeout(function () {
var text = $(el).val();
el.val(text.toUpperCase());
}, 100);
});
}
});
Thanks worked out, as change() runs after the element lose focus I have no problem with the cursor in the fields with mask.
– Alan Almeida