You are on page 1of 2

<html> <head> <script type="text/javascript"> function validarNum(e) { tecla = (document.all) ? e.keyCode : e.

which; if (tecla == 8) return true; patron = /\d/; te = String.fromCharCode(tecla); return patron.test(te); } </script> </head> <body> <input type="text" onkeypress = "return validarNum(event)" /> </body> </html>

<script> function soloLetras(e){ key = e.keyCode || e.which; tecla = String.fromCharCode(key).toLowerCase(); letras = " abcdefghijklmnopqrstuvwxyz"; especiales = [8,37,39,46]; tecla_especial = false for(var i in especiales){ if(key == especiales[i]){ tecla_especial = true; break; } } if(letras.indexOf(tecla)==-1 && !tecla_especial) return false; } </script> <input type="text" onkeypress="return soloLetras(event)">

You might also like