2016-05-04 19 views
0

は、私はselect属性が選択し、ラジオボタンに必要な属性

<select required></select> 

でなければならないことを知っている。しかし、私はそれを置くだろうか?

<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> 

をまた、どのようにCSSを持っている:(私を助けてください私は同様に必要なラジオボタンを作ることができますか?オプションを指定するその他-してくださいについて。

<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

... 'このため –

答えて

1

ラジオボタンhereを参照してください。 radiogroupの1つの入力に対して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

感謝をjqueryの-validation'を使用してください!私は実際にそれを理解しましたが、選択したフォームについてはどうですか?私はクラスの後に必要なパッティングを試みたが、それは動作しませんでした – Nnn

+0

@ Nnn私は答えを更新しました –

関連する問題