问题描述
是否有任何标准(HTML、UI、可访问性等)规定应始终选择给定单选按钮组中的一个单选按钮?
Are there any standards (HTML, UI, accessibility, and such like) that stipulate that one of the radio buttons in a given group of radio buttons should be selected at all times?
我遇到了一个业务需求,我被要求不选中组中的两个单选按钮,然后让逻辑强制用户在继续之前选择一个.
I have encountered a business requirement whereby I have been asked that both radio buttons in a group be left unchecked, and then to have logic forcing the user to select one before they can continue.
虽然我知道如何实现这一点,但感觉不对,因此我暗示了这一点,但我一直在寻找更明确地规定这一点的指南,以便我可以将其纳入我们自己的标准.
While I know how to achieve this, it felt wrong, and I intimated as such, but was looking for guidelines that stipulate this more explicitly so I can feed this into our own standards.
推荐答案
是:http://www.w3.org/TR/html401/interact/forms.html#radio
始终只选中一组中的一个单选按钮.如果一组单选按钮的任何元素都没有指定已检查",则用户代理必须首先检查该组的第一个单选按钮.
At all times, exactly one of the radio buttons in a set is checked. If none of the elements of a set of radio buttons specifies `CHECKED', then the user agent must check the first radio button of the set initially.
规范使用术语用户代理"来表示通常称为浏览器".所以规范说如果没有检查,浏览器会先检查.
The specification uses the term "user agent" for what is commonly known as "browser". So the specification says that if none is checked, the browser will check the first.
更新: 请注意,我尝试过的 4 个浏览器都没有真正做到这一点! 他们不检查第一个并且 没有 收音机是以 =on 形式提供给服务器.一个好的 Web 框架应该进行服务器端检查(无论如何都应该这样做,因为突然或伪造的 POST 可能会导致相同的结果).
UPDATE: note that none of the 4 Browsers i tried actually does this! They dont check the first and none of the radios are given as =on to the server. A good web framework should do the serverside-checking (it should do it anyway because an abrupted or forged POST could cause the same).
这篇关于是否应该始终选中单选组中的一个 HTML 单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!




大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)