Advertisement
jeffersonvv

Bloqueando Letras ou Numeros no Input

Nov 28th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. function Onlynumbers(e)
  3. {
  4.     var tecla=new Number();
  5.     if(window.event) {
  6.         tecla = e.keyCode;
  7.     }
  8.     else if(e.which) {
  9.         tecla = e.which;
  10.     }
  11.     else {
  12.         return true;
  13.     }
  14.     if((tecla >= "97") && (tecla <= "122")){
  15.         return false;
  16.     }
  17. }
  18.  
  19. function Onlychars(e)
  20. {
  21.     var tecla=new Number();
  22.     if(window.event) {
  23.         tecla = e.keyCode;
  24.     }
  25.     else if(e.which) {
  26.         tecla = e.which;
  27.     }
  28.     else {
  29.         return true;
  30.     }
  31.     if((tecla >= "48") && (tecla <= "57")){
  32.         return false;
  33.     }
  34. }
  35. </script>
  36. // Nome: <input type="text" onkeypress="return Onlychars(event)">
  37. // Telefone: <input type="text" onkeypress="return Onlynumbers(event)">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement