這篇文章給大家分享的是有關(guān)bootstrap怎么限定日期選擇器可選時(shí)間范圍的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧。
灞橋網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,灞橋網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為灞橋上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的灞橋做網(wǎng)站的公司定做!
一、應(yīng)用場(chǎng)景
實(shí)際應(yīng)用中可能會(huì)根據(jù)日期字段查詢某個(gè)日期范圍內(nèi)的數(shù)據(jù),則需要對(duì)日期選擇器可選時(shí)間進(jìn)行限制,
如:開始時(shí)間不能大于結(jié)束時(shí)間,結(jié)束時(shí)間不能小于開始時(shí)間,此時(shí)就要為開始日期選擇器和結(jié)束日期選擇器動(dòng)態(tài)的設(shè)置startDate和endDate的值。
二、相關(guān)知識(shí)點(diǎn)
1、bootstrap-datepicker的初始化
引入bootstrap-datepicker.js和bootstrap-datepicker.css
bootstrap-datepicker配置參數(shù)的了解
2、boostrap-datepicker的changeDate事件:日期改變時(shí)觸發(fā)
3、bootstrap-datepicker的setEndDate和setStartDate方法
4、詳細(xì)配置參見官方文檔http://bootstrap-datepicker.readthedocs.org/en/latest/methods.html
三、應(yīng)用實(shí)例
1、JSP中,聲明日期選擇器
<span style="font-size:14px;"><div class="col-md-6 cy-text-right-md"> <div class="form-inline"> <div class="form-group cy-mar-ver-s"> <span class="cy-pad-hor-s">最后接入時(shí)間</span> </div> <div class="input-daterange input-group" id="datepicker"> <input type="text" class="form-control" name="start" id="qBeginTime" /> <span class="input-group-addon">至</span> <input type="text" class="form-control" name="end" id="qEndTime" /> </div> <div class="form-group cy-mar-ver-s"> <button class="btn btn-primary cy-pad-rgt-s" onclick="javascript:doQuery();" type="button">搜索</button> </div> </div> </div></span>
2、JS中,對(duì)日期選擇器進(jìn)行初始化和配置
<span style="font-size:14px;"> //開始時(shí)間:
$('#qBeginTime').datepicker({
todayBtn : "linked",
autoclose : true,
todayHighlight : true,
endDate : new Date()
}).on('changeDate',function(e){
var startTime = e.date;
$('#qEndTime').datepicker('setStartDate',startTime);
});
//結(jié)束時(shí)間:
$('#qEndTime').datepicker({
todayBtn : "linked",
autoclose : true,
todayHighlight : true,
endDate : new Date()
}).on('changeDate',function(e){
var endTime = e.date;
$('#qBeginTime').datepicker('setEndDate',endTime);
});</span>3、效果圖
.jpg)

感謝各位的閱讀!關(guān)于bootstrap怎么限定日期選擇器可選時(shí)間范圍就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
分享題目:bootstrap怎么限定日期選擇器可選時(shí)間范圍
路徑分享:http://www.jbt999.com/article48/ijjgep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營(yíng)銷、網(wǎng)站策劃、網(wǎng)站導(dǎo)航、ChatGPT、虛擬主機(jī)、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)