bootstrap时间区间设置方法
我们在开发过程中经常有时间区间的要求,在多次"失败"及翻阅资料之后终于找到了适合我的方法,所以给大家分享出来.
基本需求为可以设置时间,设置时间区间,后一时间日期不可提前于前一时间日期.
需要引入:bootstrap-datepicker.js 和 bootstrap-datepicker.css (bootstrap-datepicker文件可从此链接下载:http://www.bootcss.com/p/bootstrap-datetimepicker/)
以及bootstrap的js和css...就自行下载引入吧.
其中日期的参数配置可以参考:http://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#methods
接下来就可以去编写代码了↓↓↓
首先是jsp代码:
1) 时间区间开始:
<tr>
<td><span class = "han"><center>执行开始日期:</center></span></td>
<td>
<div class = "input-append date form_datetime">
<input type="text" class = "m-wrap span3" readonly placeholder="开始日期" name = "startdate" value = "${spread.startdate }" id = "starttime" data-date-format="yyyy-mm-dd" size = "16"><span class = "add-on"><i class = "icon-calendar"></i></span>
</div>
</td>
</tr>
2) 时间区间结束
<tr>
<td><span class = "han"><center>维护结束日期:</center></span></td>
<td>
<div class = "input-append date form_datetime">
<input type="text" class = "m-wrap span3" readonly placeholder="结束日期" name = "enddate" value = "${spread.enddate }" id = "endtime" data-date-format="yyyy-mm-dd" size = "16"><span class = "add-on"><i class = "icon-calendar"></i></span>
</div>
</td>
</tr>
以上为jsp代码,其中样式可以自己去设置,接下来是<script>代码
/* 时间区间开始 */
$(function(){
$("#starttime").datetimepicker({
format:"yyyy-mm-dd",
showMeridian:true,
autoclose:true,
language:'en',
pickDate:true,
minView:2,
pickTime:true,
todayBtn:true
}).on('changeDate',function(ev){
var starttime=$('#starttime').val();
$('#endtime').datetimepicker('setStartDate',starttime);
$('#starttime').datetimepicker('hide');
});
$("#endtime").datetimepicker({
format:"yyyy-mm-dd",
showMeridian:true,
minView:2,
autoclose:true,
todayBth:true
}).on('chengeDate',function(ev){
var starttime=$('#starttime').val();
var endtime = $('#endtime').val();
if(starttime!=""&&endtime!=""){
if(!checkEndTime(starttime,endtime)){
$('#endtime').val('');
alert("开始时间要大于结束时间!");
return;
}
}
$('#starttime').datetimepicker('setEndDate',endtime);
$('#starttime').datetimepicker('hide');
});
$('#starttime').datetimepicker('setEndDate',getCurentTime());
$('#endtime').datetimepicker('setStartDate',getCurentTime());
$('#starttime').val(getCurenTime());
$('#endtime').val(getCurenTime());
});
/* 时间区间结束 */
其中的参数可以根据自己的需求去更改.如写完没效果的话可以将<script>移入代码最下边.
参数配置可以参考:http://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#methods
bootstrap时间区间设置方法的更多相关文章
- win7限制登录时间的设置方法
win7使用Net User命令行语句限制登录时间的方法: 1.单击“开始”,然后单击“运行”. 2.在“打开”框中,键入cmd,然后单击“确定”. 3..键入 net user username / ...
- 解决ssh连接超时时间(ssh timeout)的设置方法
本文介绍下,linux中ssh连接超时时间的设置方法,以避免总是被强行退出.有需要的朋友,参考下吧.有关修改ssh连接超时时间的方法,网上介绍的很多了.比如下面这个:可以减少ssh连接超时等待的时间: ...
- My97设置开始、结束 时间区间及输入框不能输入只能选择的方法
时间区间开始: <input type="text" id = "first_time" name="first_time" valu ...
- session超时时间设置方法
session超时时间设置方法 由于session值之前没有设置,以至于刚登录的网站,不到一分钟就超时了,总结了一下,原来是session过期的原因,以下是设置session时间的3个方法: 1. 在 ...
- bootstrap时间插件 火狐不显示 完美解决方法
原文链接:http://www.phpbiji.cn/article/index/id/141/cid/4.html bootstrap时间插件火狐 bootstrap-datetimepicker火 ...
- 接口调试工具ApiPost的发送超时时间设置方法
有部分使用ApiPost的同学反应:发送接口调试时,响应超时时间设置的太短导致接口访问失败,怎么设置呢? 就连百度也有很多人在搜: 今天就来说一说. ApiPost简介: ApiPost是一个支持团队 ...
- bootstrap 时间控件带(时分秒)选择器
1.控件下载地址:http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm,参数设置说明也在这个链接下面: 2.具体参数说明(复制原链接) ...
- pandas处理时间序列(2):DatetimeIndex、索引和选择、含有重复索引的时间序列、日期范围与频率和移位、时间区间和区间算术
一.时间序列基础 1. 时间戳索引DatetimeIndex 生成20个DatetimeIndex from datetime import datetime dates = pd.date_rang ...
- bootstrap 时间控件带(时分秒)选择器(需要修改才能显示,请按照参数说明后面的步骤进行修改)
1.控件下载地址:http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm,参数设置说明也在这个链接下面: 2.具体参数说明(复制原链接) ...
随机推荐
- 本站已稳定运行了XX天,网页时间显示功能实现方法
这个是我昨晚上添加的效果, 分为三个部分: 1.本站已稳定运行了多少天的实现: 直接把下面代码复制到后台你想添加的位置即可. 1 2 3 4 5 6 7 8 9 本站已稳定运行了 <strong ...
- Unity 读取资源(图片)
方法一: 采用Resource.Load方法读取,读取在Unity中Assets下Resources目录下的资源名(不采用后缀). //图片放在Asset/Resources/ Texture2D t ...
- Python 3.6.4 / win10 使用pip安装keras时遇到依赖的PyYAML安装出错
PS C:\Users\myjac\Desktop\simple-chinese-ocr> pip install keras Collecting keras Downloading http ...
- firemonkey ListView DynamicAppearance
Go Up to FireMonkey Application Design Contents [hide] 1 Customizing the List View Appearance Prope ...
- 前端dom元素的操作优化建议
参考自:http://blog.csdn.net/xuexiaodong009/article/details/51810252 其实在web开发中,单纯因为js导致性能问题的很少,主要都是因为DOM ...
- 前端的UI设计与交互之设计原则篇
1.亲密性 a)纵向间距示例这三种规格分别为:8px(小号间距).16px(中号间距).24px(大号间距). b)在这三种规格不适用的情况下,可以通过加减『基础间距』的倍数,或者增加元素来拉开信息层 ...
- java File类常用方法
file类常用方法 delete()删除此抽象路径名表示的文件和目录. equals()测试此抽象路径名与给定对象是否相等. exists()测试此抽象路径名表示的文件或目录是否存在. getName ...
- RabbitMQ第四篇:Spring集成RabbitMQ
前面几篇讲解了如何使用rabbitMq,这一篇主要讲解spring集成rabbitmq. 首先引入配置文件org.springframework.amqp,如下 <dependency> ...
- Webpack的基本配置
一.优化项目结构,创建相关的文件,项目结构如下:src文件夹存放相关js文件,index.html项目的首页面,dist文件夹是webpack 打包 目录. index.js内容为: alert('我 ...
- 在Node应用中避免“Dot Hell”
转载自:http://blog.leapoahead.com/2015/09/03/prevent-node-require-dot-hell/ 在Node应用中,我们使用require来加载模块.在 ...