如何js中判断页面上选择框中输入的两个日期的差值小于31
2017-10-31 10:02
489 查看
也许我这种办法比较笨,如果你有更好的办法,我希望能与我沟通。
先说一下需求:
页面上有两个选择时间的下拉框,如图
我需要完成的是账单结束时间和账单开始时间的差值在31天,因为数据太大,所以限制导出的数据量,然后我是这样实现的:
var start_time=$("#billcycle_start").val();
var end_time=$("#billcycle_end").val();
var a = new Array(3);
var b = new Array(3);
a=start_time.split('-');
b= end_time.split('-');
if(data_arr.length==0){
finedo.message.info("查询为空时不可导出");
return;
}else if(start_time==''||end_time==''){
finedo.message.info("请选择开始时间和结束时间");
}
else{
if(a[0]==b[0]){
if(a[1]==b[1]){
finedo.message.tip('正在导出请稍后...');
$("#downiframe").attr('src', '${ctx}/finedo/billsync/exportexcel' + (param ? '?' + $.param(param) : ''));
}else{
if(b[1]-a[1]==1){
if(b[2]<=a[2]){
finedo.message.tip('正在导出请稍后...');
$("#downiframe").attr('src', '${ctx}/finedo/billsync/exportexcel' + (param ? '?' + $.param(param) : ''));
}else{
finedo.message.info("请选择在一个月内的数据");
}
}else{
finedo.message.info("请选择在一个月内的数据");
}
}
}else{
finedo.message.info("请选择在一个月内的数据");
}
}先将年份进行比较,然后月份进行比较,如果月份相等,就直接导出,如果月份不相等,在对日进行比较,如果end_time的当前日小于start_time的当前日,也可以直接导出,否则是不可以的。
先说一下需求:
页面上有两个选择时间的下拉框,如图
我需要完成的是账单结束时间和账单开始时间的差值在31天,因为数据太大,所以限制导出的数据量,然后我是这样实现的:
var start_time=$("#billcycle_start").val();
var end_time=$("#billcycle_end").val();
var a = new Array(3);
var b = new Array(3);
a=start_time.split('-');
b= end_time.split('-');
if(data_arr.length==0){
finedo.message.info("查询为空时不可导出");
return;
}else if(start_time==''||end_time==''){
finedo.message.info("请选择开始时间和结束时间");
}
else{
if(a[0]==b[0]){
if(a[1]==b[1]){
finedo.message.tip('正在导出请稍后...');
$("#downiframe").attr('src', '${ctx}/finedo/billsync/exportexcel' + (param ? '?' + $.param(param) : ''));
}else{
if(b[1]-a[1]==1){
if(b[2]<=a[2]){
finedo.message.tip('正在导出请稍后...');
$("#downiframe").attr('src', '${ctx}/finedo/billsync/exportexcel' + (param ? '?' + $.param(param) : ''));
}else{
finedo.message.info("请选择在一个月内的数据");
}
}else{
finedo.message.info("请选择在一个月内的数据");
}
}
}else{
finedo.message.info("请选择在一个月内的数据");
}
}先将年份进行比较,然后月份进行比较,如果月份相等,就直接导出,如果月份不相等,在对日进行比较,如果end_time的当前日小于start_time的当前日,也可以直接导出,否则是不可以的。
相关文章推荐
- js 时间日期 校验格式 比较大小等(判断页面选择时间只能在早8点到晚8点之间)
- 如何用js判断两个文本框里的日期是否在同一个月里???
- 很不错的js日期控件/在jsp页面弹出选择日期
- js判断页面输入框未输入内容或者输入的内容为空格
- js判断输入值为整数,输入值的和小于固定值
- js如何判断输入是否为整数
- js判断输入字符串长度(汉字算两个字符,字母数字算一个)
- js判断两个日期的大小先后
- 判断输入的日期字符串是否小于当前日期
- js判断两个日期之间相差多少天
- 如何利用JS判断当前来路域名并跳转到指定页面
- 从select中选择option后如何转到相应的数据页面中去的JS代码
- Mysql日期差函数,Mysql选择两个日期字段相差大于或小于一定时间
- JS判断两个日期的差或者判断两个日期的大小
- 页面上有两个元素id相同,js中如何取值
- underscore.js中如何判断两个对象的内容相同
- 输入一个日期,****年**月**日,如何判断是否为工作日?
- 一个JS日期选择器比较不能小于开始时间的JS脚本
- js 如何判断页面里的某个值改变
- js判断两个日期之间的天数差