0
good night. I have this field with mask when typing Cpf, it happens that if copy/paste it does not apply the mask, only the numbers.
how can I have the 2 forms of mask in imput?
function formatar(mascara, documento){
var i = documento.value.length;
var saida = mascara.substring(0,1);
var texto = mascara.substring(i)
if (texto.substring(0,1) != saida){
documento.value += texto.substring(0,1);
}
}
o input:
<input type="text" name="ao_cpf" id="ao_cpf" placeholder="CPF" maxlength="14" OnKeyPress="formatar('###.###.###-##', this)" />
Have you tried with
onpaste
oroninput
?– Sergio
as well, in input or java?
– user26858
In the HTML element:
onpaste="formatar('###.###.###-##', this)" oninput="formatar('###.###.###-##', this)"
– Sergio
copy/paste did not work...
– user26858
You have tried Maskedinput: https://plugins.jquery.com/maskedinput/
– Wilson Rosa Gomes