阻止提交HTML表单字段 [英] Preventing an HTML form field from being submitted
本文介绍了阻止提交HTML表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以编程方式允许或隐藏HTML 5表单中未提交的表单字段.我以为我可以将其CSS display
属性设置为 none
.但是,它仍然会被提交(无法看到).我可以设置另一个属性,而不是完全将元素从HTML5文档中删除吗?
I want to programmatically allow or hide a form field from being submitted in an HTML5 form. I thought I could just set its CSS display
attribute to none
. However, it still gets submitted (just can't be seen). Is there another property I can set rather than removing the element completely from the HTML5 document?
推荐答案
只需为表单字段设置 disabled
属性,例如
Simply set disabled
attribute for the form field, e.g.
<input name="test" value="test" disabled="disabled">
REF:: http://www.w3.org/TR/html401/interact/forms.html#h-17.12.1
这篇关于阻止提交HTML表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文