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