2017-10-20 76 views
0

爲什麼我不能在我的選擇選項使用required ATTRIB我想用所需的屬性

<form> 
 
<select required="" name="Furniture" id="Furniture" class="form-control input-lg" > 
 
    <option value="" disabled selected>Select Furniture</option> 
 
</form>

+0

你是指什麼意思?你的'button'或'input' type =「submit」'在哪裏? –

+0

我需要的屬性似乎不起作用 –

+0

這裏'' –

回答

0

嘗試使用所需要的屬性沒有="",如下:

<select required> 
    <option value="">Select Furniture</option> 
</select> 

必需屬性是布爾屬性。

存在時,它指定在提交表單之前必須填寫輸入字段 。

+0

我不認爲這是問題... OP使用'input type =「按鈕」'而不是'input type =「submit」'。 –

0

必需是布爾屬性。如果該屬性存在,則表示所需屬性的值爲true,否則爲false。它如果你使用HTML5,只需要寫不需要雙引號。 試試這個:

<form> 
<select required name="Furniture" id="Furniture" class="form-control input-lg" > 
    <option value="" disabled selected>Select Furniture</option> 
</form> 
+0

我不認爲這是問題...... OP使用'input type =「按鈕」'而不是'input type =「submit」'。 –