
function mascara_cpf() { 
if(document.form.cpf.value.length == 3) { 
document.form.cpf.value += '.'; 
} 
if(document.form.cpf.value.length == 7) {
document.form.cpf.value += '.'; 
}
if(document.form.cpf.value.length == 11) { 
document.form.cpf.value += '-'; 
}
}

function mascara_data() {
if(document.form.data.value.length == 2) {
document.form.data.value += '/';
}
if(document.form.data.value.length == 5) {
document.form.data.value += '/';
}
}


function mascara_cep() {
if(document.form.cep.value.length == 5) {
document.form.cep.value += '-';
}
}


function mascara_telefone() {
if(document.form.telefone.value.length == 0) {
document.form.telefone.value += '(';
}
if(document.form.telefone.value.length == 3) {
document.form.telefone.value += ') ';
}
if(document.form.telefone.value.length == 9) {
document.form.telefone.value += '-';
}
}


function mascara_cartao() {
if(document.form.cartao.value.length == 4) {
document.form.cartao.value += '.';
}
if(document.form.cartao.value.length == 9) {
document.form.cartao.value += '.';
}
if(document.form.cartao.value.length == 14) {
document.form.cartao.value += '.';
}
}

/*
<form name=form>
Cpf: <input type=text name=cpf onKeyUp="mascara_cpf()" maxlength=14><br>
Data: <input type=text name=data onKeyUp="mascara_data()" maxlength=10><br>
CEP: <input type=text name=cep onKeyUp="mascara_cep()" maxlength=9><br>
Telefone: <input type=text name=telefone onKeyUp="mascara_telefone()" maxlength=12><br>
Cartão: <input type=text name=cartao onKeyUp="mascara_cartao()" maxlength=19>
</form>
*/
