我正在面對我正在使用的Bootstrap驗證器的一個奇怪問題。這裏有一個工作小提琴:https://jsfiddle.net/p6jytvLj/ 注意:調整輸出窗口的大小,以查看實際的形式。水平表單的Bootstrap驗證
HTML代碼
<form class="form-horizontal" id="main-form" role="form" method="post">
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" for="inputProjectID">Project ID </label>
<div class="col-md-3 col-3-input">
<input id="inputProjectID" name="inputProjectID" type="text" placeholder="Your Project ID" class="form-control input-md">
</div>
<label class="col-md-2 control-label" for="inputProjectName">Project Name </label>
<div class="col-md-3 col-3-input">
<input id="inputProjectName" name="inputProjectName" type="text"
placeholder="Your Project Name" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" for="datepicker">Release Date </label>
<div class="col-md-3 col-3-input">
<input id="datepicker" name="inputReleaseDate" type="text"
placeholder="Select Release Date" class="form-control input-md">
</div>
<label class="col-md-2 control-label" for="inputSupervisor">Supervisor </label>
<div class="col-md-3 col-3-input">
<input id="textinput" name="textinput" type="text" placeholder="Your Supervisor's Name" class="form-control input-md">
</div>
</div>
<!-- Text area -->
<div class="form-group">
<label class="col-md-2 control-label" for="inputProjectDesc">Project Description </label>
<div class="col-md-9 col-9-input">
<textarea style="resize: none;" rows="3" class="form-control" id="inputProjectDesc"
name="inputProjectDesc" placeholder="Your Project Description"></textarea>
</div>
</div>
<button type="submit" class="btn btn-success" form="main-form" data-toggle="tooltip"
title="Click to submit this form" onclick="submitForms()">Submit</button>
</form>
JS
$(document).ready(function() {
$('#main-form').bootstrapValidator({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
inputProjectID: {
row: 'col-md-3',
validators: {
notEmpty: {
message: 'The Project ID is required'
}
}
},
inputProjectName: {
row: 'col-md-3',
validators: {
notEmpty: {
message: 'The Project Name is required'
}
}
},
inputReleaseDate: {
validators: {
notEmpty: {
message: 'Please select a Release Date'
}
}
}
}
});
});
的問題,我面對的是我只對前三個字段,即專案編號,項目名稱&發佈日期設置驗證。只要我點擊提交按鈕,引導程序錯誤類也適用於相鄰的現場主管。任何想法如何防止這種情況發生?
在超級添加其他類輸入字段並設置爲默認的邊框顏色 –