0
我是編碼世界的新手。我正在使用bootstrap製作一個網頁,在頁面中輸入「開始日期」和「結束日期」。但問題是我不知道如何使結束日期總是大於開始日期。我在這裏粘貼了我從互聯網上獲得的代碼。任何幫助將不勝感激This is how the page looks like right now如何比較結束日期和引導程序中的開始日期以確保結束日期大於開始日期
<script>
$(document).ready(function() {
$('#dateRangePicker')
.datepicker({
format: 'mm/dd/yyyy',
startDate: '01/01/2010',
endDate: '12/30/2020'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#dateRangeForm').formValidation('revalidateField', 'date');
});
$('#dateRangePicker1')
.datepicker({
format: 'mm/dd/yyyy',
startDate: '01/01/2010',
endDate: '12/30/2020'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#dateRangeForm').formValidation('revalidateField', 'date');
});
$('#dateRangeForm').formValidation({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
date: {
validators: {
notEmpty: {
message: 'The date is required'
},
date: {
format: 'MM/DD/YYYY',
min: '01/01/2010',
max: '12/30/2020',
message: 'The date is not a valid'
}
}
}
}
});
});
</script>
<div class="form-group">
<label class="control-label col-sm-3">Start Date</label>
<div class="col-sm-6">
<div class="input-group input-append date" id="dateRangePicker">
<input type="text" class="form-control" name="date" />
<span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">End Date</label>
<div class="col-sm-6">
<div class="input-group input-append date" id="dateRangePicker1">
<input type="text" class="form-control" name="date" />
<span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
</div>
問題是我沒有使用JSP的經驗。所以,如果我可以得到一個明確的代碼,說明如何使用startDate和endDate並比較它們,比如endDate - startDate> 0,那麼它會很棒。 –