Posted By

mate on 06/30/06


Tagged

html


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

luman
meth


Utilizar la tecla intro como un tabulador de formulario


 / Published in: JavaScript
 

extraido de http://www.bloglines.com/myblogs

  1. <script type="text/javascript">
  2. function handleEnter (field, event) {
  3. var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  4. if (keyCode == 13) {
  5. var i;
  6. for (i = 0; i < field.form.elements.length; i++)
  7. if (field == field.form.elements[i])
  8. break;
  9. i = (i + 1) % field.form.elements.length;
  10. field.form.elements[i].focus();
  11. return false;
  12. }
  13. else
  14. return true;
  15. }
  16. </script>
  17.  
  18. HTML:
  19.  
  20. <form action="http://www.google.es">
  21. Nombre:
  22. <input onkeypress="return handleEnter(this, event)" name="nombre">
  23. <br>
  24. Apellidos:
  25. <input onkeypress="return handleEnter(this, event)" name="apellidos">
  26. <br>
  27. Email:
  28. <input onkeypress="return handleEnter(this, event)" name="email">
  29. <br>
  30. Comentarios:
  31. <textarea rows=6 cols=40>

Report this snippet  

You need to login to post a comment.