Simular submit al hacer enter y tener un boton type="button"


/ Published in: JavaScript
Save to your folder(s)

Simular submit al hacer enter y tener un boton type="button"


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2.  
  3. function login()
  4. {
  5. // funcion
  6. }
  7.  
  8. function chequearEnter(event) {
  9. if (event.keyCode == 13) { login(); }
  10. }
  11. </script>
  12.  
  13. <table width="400px" align="center">
  14. <tr><td colspan="2"></td></tr>
  15. <tr>
  16. <td>Usuario</td>
  17. <td><input type="text" name="txtNombre" id="txtNombre" onkeypress="chequearEnter(event)"></td>
  18. </tr>
  19. <tr>
  20. <td>Clave</td>
  21. <td><input type="password" name="txtClave" id="txtClave" onkeypress="chequearEnter(event)"></td>
  22. </tr>
  23. <tr><td colspan="2"></td></tr>
  24. <tr>
  25. <td colspan="2" align="center"><input type="button" value="Entrar" onclick="login()"></td>
  26. </tr>
  27. </table>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.