HTML:复选框默认值 [英] HTML: Checkbox default value
问题描述
当我使用复选框提交的HTML表单没有明确定义的值
时,Chrome会在$ c $上发送 c>作为该字段的值。
When I submit a HTML form with a checked checkbox that doesn't have an explicitly defined value
, Chrome sends on
as a value for that field.
这是标准行为吗?或者我可以从其他浏览器中得到什么?
Is that the standard behavior? Or what can I expect from other browsers?
推荐答案
HTML 4.01规范没有指定复选框的值。它只是指它说它是开,但这只是散文,并没有说明默认值是什么。但它也表示(根据对 input
元素),在这种情况下需要值
属性。
The HTML 4.01 specification does not specify the value of a checked checkbox. It just refers it saying that it is "on", but this is just prose and does not say what the default value is. But it also says (under the description of the input
element) that the value
attribute is required in this case.
因此,< input type = checkbox name = foo>
对于所使用的值具有未定义的行为,尽管实际上浏览器使用值= on
作为默认值。
So <input type=checkbox name=foo>
has undefined behavior as regards to the value used, though in practice browsers use value=on
as the default.
这篇关于HTML:复选框默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!