Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

michaelmika

Mascara de CPF

Recommended Posts

tenho essa mascara em javascript

 

//MASCARA CPF

function validaCPF(cpf){

if(cpf.value.length== 3){

cpf.value+="."

}

if(cpf.value.length== 7){

cpf.value+="."

}

if(cpf.value.length== 11){12

cpf.value+="-"

}

}

 

e gostaria de acrescentar essa junto pra chamar ela junto

 

 

<script>

 

function numeros(ie, ff) {

if (ie) {

tecla = ie;

} else {

tecla = ff;

}

 

/**

* 13 = [ENTER]

* 8 = [backSpace]

* 9 = [TAB]

* 46 = [Delete]

* 48 a 57 = São os números

*/

if ((tecla >= 48 && tecla <= 57) || (tecla == 8) || (tecla == 13) || (tecla == 9) || (tecla == 46)) {

return true;

}

else {

return false;

}

}

 

</script>

 

 

e os input

 

<input type="text" name="cpf" value="cpf" onkeypress="validaCPF(this)" maxlength="14">

<input size="80" type="text" onkeypress="return numeros(event.keyCode, event.which);" />

 

gsotaria de deixar tudo no msm...como faço...

Compartilhar este post


Link para o post
Compartilhar em outros sites

veja essa para CPF com ER, funciona perfeitamente, e faz as 2 funções que você quer:

http://wbruno.com.br/2011/03/12/diversas-mascaras-com-er/

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.