2016-05-04 22 views
0

請幫我:(我知道,選擇屬性應該是選擇和所需的單選按鈕屬性

<select required></select> 

但是我有一個CSS我會怎麼說呢?

<div class="col-md-6"> 
          <div class="form-group"> 
           <label for="sel1">Which division of our company are you interested in *</label> 
           <select class="form-control" id="sel1"> 
           <option>Please select one</option> 
           <option>Video game consoles and accessories</option> 
           <option>Gaming and entertainment gift cards/codes</option> 
           <option>Both</option> 
           </select> 
          </div> 
          </div> 

此外,如何我可以把所需的單選按鈕呢?換了別人,請註明選項。

<div class="col-md-6"> 

           <label for="form_business">Type of business *</label> 
           <div>          
            <label class="radio-inline" style="padding-left:30px;"> 
            <input type="radio" name="optradio">Retailer 
            </label> 

            <label class="radio-inline"> 
            <input type="radio" name="optradio">Other - Please specify 
            </label> 
            <input id="form_other" type="text" name="other" class="form-control" placeholder="Please specify"> 
            </div> 
           </div> 
+0

使用'jQuery的validation' .. –

回答

1

單選按鈕: 參見here。您只需要爲radiogroup的一個輸入設置required屬性,但您可以爲所有設置。

<div> 
    <label class="radio-inline" style="padding-left:30px;"> 
    <input type="radio" name="optradio" required>Retailer 
    </label> 

    <label class="radio-inline"> 
    <input type="radio" name="optradio">Other - Please specify 
    </label> 
    <input id="form_other" type="text" name="other" class="form-control" placeholder="Please specify"> 
</div> 

對於選擇:強制性擁有的第一個值空 - 空值換需要的作品。 see more

<select class="form-control" id="sel1" required> 
    <option value="">Please select one</option> 
    <option>Video game consoles and accessories</option> 
    <option>Gaming and entertainment gift cards/codes</option> 
    <option>Both</option> 
</select> 

小提琴here

+0

感謝這個!我其實已經想通了,但選擇表單怎麼樣?我嘗試在課後放置所需但它沒有工作 – Nnn

+0

@Nnn我已經更新了答案 –