如何按ENTER键发送表单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何按ENTER键发送表单相关的知识,希望对你有一定的参考价值。
Suppose you have a login form and you want to send the form when user press enter on his keyboard and not only by clicking on the submit button.This can be achieved capturing a specific event when the user is typing. We have to capture the keypress event and listen to trigger an action when the enter key is pressed. Example and code in the link above.
function submitonenter(formid,evt,thisObj) { evt = (evt) ? evt : ((window.event) ? window.event : "") if (evt) { // process event here if ( evt.keyCode==13 || evt.which==13 ) { thisObj.blur(); document.getElementById(formid).submit(); } } } </script>
以上是关于如何按ENTER键发送表单的主要内容,如果未能解决你的问题,请参考以下文章
如何通过按 Enter 使用 Dojo 和 XHR 发送 Zend 表单
如何使用 react-native-testing-library 提交表单或在输入上按 enter 键