在带有“已禁用”选项的下拉表单元素上使用“required”可在Firefox中使用,以防止用户提交表单而不从下拉列表中选择内容,但不在Chrome中。你能帮忙吗?
<select id="topic" class="form-control" required="required">
<option disabled selected>select genre</option>
<option>All genres (whatever works)</option>
<option>boogers</option>
<option>cheese</option>
<option>dumplings</option>
</select>
答案 0 :(得分:0)
这可能有用
<option selected="true" disabled="disabled">select genre</option>
答案 1 :(得分:0)
要使其正常工作,只需将value=""
添加到默认选项即可。这个答案提供了一些关于此事的HTML5文档。
Can I apply the required attribute to <select> fields in HTML5?