HTML:复选框默认值 [英] HTML: Checkbox default value

查看:436
本文介绍了HTML:复选框默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用复选框提交的HTML表单没有明确定义的时,Chrome会在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆