我有一個簡單的表單,帶有文本輸入和兩個複選框,我需要在複選框中設置屬性「required」(我需要至少選中其中一個複選框)。設置引導程序中複選框所需的屬性
<div class="control-group">
<label class="control-label" for="inputEmail"><?= $this->labelfieldEmail; ?></label>
<div class="controls">
<input type="text" name="email" id="emailField"
placeholder="Email" required>
</div>
</div>
<div class="control-group">
<label class="control-label" for="productField"><?= $this->labelfieldProduct; ?></label>
<div class="controls" >
<input type="checkbox" id="inlineCheckbox1" value="widget" name="product[]" <?php if ($this->selectedProduct == "widget") { echo "checked"; }?>/>
Widget for website
<br/>
<input type="checkbox" id="inlineCheckbox2" value="app" name="product[]" <?php if ($this->selectedProduct == "app") { echo "checked"; }?>/>
App mobile
</div>
</div>
請問,有什麼建議嗎?
編輯
我試圖在後續的方式來使用jqBootstrapValidation庫,但它不工作: 1.添加庫 2.添加到這個<head>
標籤:
<script>
$(function() {
$("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
});
</script>
3這是我的表單代碼:
<form class="form-horizontal" method="POST" action="<?= $this->baseUrl($this->pathBusinessThankyou);?>">
<div class="row-fluid">
<div class="row-fluid">
<br />
<div class="control-group">
<label class="control-label" for="inputName"><?= $this->labelfieldName; ?></label>
<div class="controls">
<input type="text" id="fullnameField" name="fullname" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail"><?= $this->labelfieldEmail; ?></label>
<div class="controls">
<input type="email" id="emailField" name="email" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="productField"><?= $this->labelfieldProduct; ?></label>
<div class="controls" >
<label class="checkbox">
<input type="checkbox"
data-validation-minchecked-message="<?= $this->validationOneProduct; ?>"
data-validation-minchecked-minchecked="1" value="widget" name="product[]"
<?php if ($this->selectedProduct == "widget") { echo "checked"; }?> />
Widget per il tuo sito
</label>
<label class="checkbox">
<input type="checkbox" value="app" name="product[]" aria-invalid="false"
<?php if ($this->selectedProduct == "app") { echo "checked"; }?> />
App per il tuo hotel
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail"><?= $this->labelfieldNote; ?></label>
<div class="controls">
<textarea rows="3" name="comment" id="commentField"></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn input-block-level btn-large btn-success">
<?= $this->labelSendRequest; ?>
<i class="icon-ok icon-white"></i>
</button>
</div>
</div>
</div>
</div>
</form>
謝謝,我打算使用該庫,但它不起作用。 我已遵循documetation上的免費步驟,但它不起作用 – Dany
您是否有任何外部鏈接可以查看您有哪些類型的問題? –
不,不幸的。但是我編輯了我的問題 – Dany