Posted By

elquemero on 11/11/10


Tagged

javascript html input validation


Versions (?)

No permitir ingresar ciertos caracteres en un input


 / Published in: JavaScript
 

URL: http://www.telefonica.net/web2/blas-mar/validarformu.html

  1. function validarn(e) { // 1
  2. tecla = (document.all) ? e.keyCode : e.which; // 2
  3. if (tecla==8) return true; // 3
  4. if (tecla==9) return true; // 3
  5. if (tecla==11) return true; // 3
  6. patron = /[A-Za-zñÑ'áéíóúÁÉÍÓÚàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛÑñäëïöüÄËÏÖÜ\s\t]/; // 4
  7.  
  8. te = String.fromCharCode(tecla); // 5
  9. return patron.test(te); // 6
  10. }
  11.  
  12.  
  13.  
  14. <input type="text" class="inputText" name="nombre" onkeypress="return validarn(event)" />

Report this snippet  

You need to login to post a comment.