过滤日期为jan30,31,feb-01无法使用javascript工作 [英] Filter dates for jan30, 31 with feb-01 not working using javascript

查看:87
本文介绍了过滤日期为jan30,31,feb-01无法使用javascript工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想过滤掉日期和日期。

当我在1月30日用fromDate搜索时2017年至2017年2月1日至2017年日期显示消息ToDate不能低于FromDate。



注:

Senario 1:每年特别搜索1月30日至2月1日。

Senario 2:每年搜索特别是1月31日至2月1日。



在其他情况下工作正常。



Hi,

I would like to filter fromDate and toDate.
when i am doing search with fromDate as Jan -30-2017 and toDate as Feb-01-2017 it is showing a message "ToDate" Cannot be less than "FromDate".

Note:
Senario 1: For Every year search for particularly Jan-30 To Feb-01.
Senario 2: For Every year search for particularly Jan-31 To Feb-01.

In other cases working fine.

ValidateDate(fromDate,toDate){

var pDay=parseInt(toDtae.substring(0,2),10);
var pMon=parseInt(toDtae.substring(0,2),10);
var pYear=parseInt(toDtae.substring(0,2),10);
var pDate=new Date(pYear,pMon,pDay);

var oDay=parseInt(toDtae.substring(0,2),10);
var oMon=parseInt(toDtae.substring(0,2),10);
var oYear=parseInt(toDtae.substring(0,2),10);
var oDate=new Date(oYear,oMon,oDay);

if(pDate<oDate){
confirm('<s:Text name="labe.dateerrorMessage"/>')
documentation("okButton").disabled=true;
}
}



每当我从1月30日/ 31日到2月01日期间搜索它每年都显示

ToDate不能低于FromDate。



示例:fromDate:jan302017

toDate:Feb012017

选择是通过Calander啊。



我尝试过:




whenever i am searching fromDate Jan 30/31 to Feb 01 for Every year it is showing
"ToDate" Cannot be less than "FromDate".

Example: fromDate:jan302017
toDate:Feb012017
selection is ahppening through Calander.

What I have tried:

ValidateDate(fromDate,toDate){

var pDay=parseInt(toDtae.substring(0,2),10);
var pMon=parseInt(toDtae.substring(0,2),10);
var pYear=parseInt(toDtae.substring(0,2),10);
var pDate=new Date(pYear,pMon,pDay);

var oDay=parseInt(toDtae.substring(0,2),10);
var oMon=parseInt(toDtae.substring(0,2),10);
var oYear=parseInt(toDtae.substring(0,2),10);
var oDate=new Date(oYear,oMon,oDay);

if(pDate<oDate){
confirm('<s:Text name="labe.dateerrorMessage"/>')
documentation("okButton").disabled=true;
}
}

推荐答案

好的,所以你想要一个简单的JavaScript日期比较。



Okay, so you want a simple JavaScript date comparison.

function ValiDate(startText,endText) //get it?
{
   var startDate = new Date(startText), 
       endDate = new Date(endText);

   if(startDate.getTime() > endDate.getTime()){
      alert('ZOMG errorz');
      document.getElementById('okButton').disabled = true;
   }
}


这篇关于过滤日期为jan30,31,feb-01无法使用javascript工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆