本文介紹了html5:復選框/收音機中名為 required 的屬性的意義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
在提交表單時,您怎么可能將復選框/單選按鈕標記為必需?
On form submission, how could you possibly mark a checkbox/radiobutton as required?
靈感來源:Pekka的回答 問題
推薦答案
必填復選框并不少見.幾乎每個注冊表單都使用某種形式的我已閱讀并接受用戶協議"復選框.
Required checkboxes are not unusual. Practically every registration form uses some form of the "I have read and accept the User Agreement" checkbox.
如果你有 Opera,試試下面的代碼.除非選中復選框,否則表單不會提交.
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="/">
<input type="checkbox" required="required" id="cb" name="cb">
<label for="cb">required checkbox</label>
<input type="submit">
</form>
</body>
</html>
這篇關于html5:復選框/收音機中名為 required 的屬性的意義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!