javascript如何防止回车(enter)键提交表单?
How does javascript prevent the enter key from submitting a form? -PHP Chinese website Q&A-How does JavaScript prevent the Enter key from submitting a form? -PHP Chinese website Q&A
Let’s take a look and learn.
如何防止回车(enter)键提交表单,其实很简单,就一句话。
onkeydown="if(event.keyCode==13)return false;"
把这句写在from标签里面就好了。如果在页面中按Enter键会自动提交的话,可以设置返回值防止自动提交如
<input id="q" name="q" type="text" onkeypress="javascript:return gosearch();">
返回值必须是false
How does javascript prevent the enter key from submitting a form? -PHP Chinese website Q&A-How does JavaScript prevent the Enter key from submitting a form? -PHP Chinese website Q&A
Let’s take a look and learn.
如何防止回车(enter)键提交表单,其实很简单,就一句话。
把这句写在from标签里面就好了。
如果在页面中按Enter键会自动提交的话,可以设置返回值防止自动提交如
返回值必须是false