HTML5:命名要求复选框/收音机属性的意义。 [英] html5: Significance of attribute named required in checkbox/radio

查看:130
本文介绍了HTML5:命名要求复选框/收音机属性的意义。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表单提交,怎么可能要求你可能标志着一个复选框/单选按钮?

On form submission, how could you possibly mark a checkbox/radiobutton as required?

灵感来源:佩卡的<一个href=\"http://stackoverflow.com/questions/4901410/correct-way-to-do-html5-checkbox/4901438#4901438\">answer到<一个href=\"http://stackoverflow.com/questions/4901410/correct-way-to-do-html5-checkbox/4901438\">question

推荐答案

所需的复选框并不罕见。实际上,每个登记表使用某种形式的我已阅读并接受用户协议复选框。

Required checkboxes are not unusual. Practically every registration form uses some form of the "I have read and accept the User Agreement" checkbox.

如果您有歌剧得心应手试用code以下。除非该复选框被选中的表单不会提交。

If you have Opera handy try out the code below. The form won't submit unless the checkbox is checked.

<!doctype html>
<html>
<head>
<title>html5</title>
</head>
<body>
<h1>html5 test</h1>
<form action="cb.html">
<input type="checkbox" required="required" id="cb" name="cb">
<label for="cb">required checkbox</label>
<input type="submit">
</body>
</html>

这篇关于HTML5:命名要求复选框/收音机属性的意义。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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