Tenhu uma mascara de telefone e não quero que a pessoa tenha a possibilidade de digitar letras, só quero que ela digite números... mas não to conseguindo fazer! Alguem pode me ajudar?
Essa é a função:
<script language="JavaScript">
function FormataValor(campo,tammax,teclapres) {
var tecla = teclapres.keyCode;
vr = document.form[campo].value;
vr = vr.replace( "-", "" );
vr = vr.replace( "-", "" );
tam = vr.length;
if (tam < tammax && tecla != 8){ tam = vr.length + 1; }
if (tecla == 8 ){ tam = tam - 1; }
if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
if ( tam <= 4 ){
document.form[campo].value = vr; }
if ( (tam > 4) && (tam <= 8) ){
document.form[campo].value = vr.substr( 0, tam - 4 ) + '-' + vr.substr( tam - 4, tam ); }
}
}
</script>
<html>
<form method="POST" name="form">
<input type="Text" name="valor" size="10" maxlength="9" onKeyDown="FormataValor('valor', 13, event)">
</form>
</html>
VALEU!!!












