I'm trying to have a clear button inside a html form, but it appears to automatically submit. How do I work around this?
我试图在html表单中有一个清晰的按钮,但它似乎自动提交。我该如何解决这个问题?
I feel like I am missing something obvious.
我觉得我错过了一些明显的东西。
Thank you, I have a working answer ... so now I'm just curious. Is there any reason to use the button element in a form, or any reason not to?
谢谢,我有一个有效的答案...所以现在我只是好奇。是否有任何理由在表单中使用按钮元素,或者没有任何理由?
4 个解决方案
#1
You have to make the type of the input element "reset
", not "submit
".
您必须使输入元素的类型为“重置”,而不是“提交”。
edit: fixed .. reset, not clear
编辑:修复..重置,不清楚
#2
<input type="reset" name="reset" value="Reset Form">
#3
Try this:
<input type="reset" name="reset" value="Clear"/>
#4
try this, instead of submit button :
试试这个,而不是提交按钮:
<input type="reset" value="Clear Form">
#1
You have to make the type of the input element "reset
", not "submit
".
您必须使输入元素的类型为“重置”,而不是“提交”。
edit: fixed .. reset, not clear
编辑:修复..重置,不清楚
#2
<input type="reset" name="reset" value="Reset Form">
#3
Try this:
<input type="reset" name="reset" value="Clear"/>
#4
try this, instead of submit button :
试试这个,而不是提交按钮:
<input type="reset" value="Clear Form">