本文介绍了需要以javascript格式从“webdatechooser”获取日期“dd / MM / yyyy”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在Aspx页面上有一个WebDateChooser来获取日期。有2个WebDatechooser One用于FROMDATE和其他用于TODATE。我需要点击或编辑检查那些日期彼此。条件从日期不能大于Todate和Todate不能少于Fromdate。需要使用Javascript为此目的。我尝试了一种方法。任何简单的方法。??
我尝试过:
Hi All,
I have a WebDateChooser in Aspx page to take Dates. There 2 WebDatechooser One for FROMDATE and other For TODATE. I need On click or on edit check those dates each other.Condition From date can't be greater than Todate and Todate Can't be less than Fromdate. Need to use Javascript for This purpose.I tried one method. Any Easy ways.??
What I have tried:
var fromDate = "";
var ToDate = "";
function GetFromDate(FromDate) {
fromDate = FromDate.getValue().format('dd/MM/yyyy');
ToDate = document.getElementById(document.getElementById("hdnToDate").value).value;
if (ToDate != "") {
var d = ToDate.slice(0, 10).split('-');
if (d[1].length == 1)
d[1] = '0' + d[1];
if (d[2].length == 1)
d[2] = '0' + d[2];
ToDate = d[2] + '/' + d[1] + '/' + d[0]; // 30/12/2010
if (ValidateDates(fromDate, ToDate)) {
ShowMessage($("#hdnTodaeFromDateMessage").val());
FromDate.setValue();
}
}
}
function GetToDate(selectedDate) {
ToDate = selectedDate.getValue().format('dd/MM/yyyy');
fromDate = document.getElementById(document.getElementById("hdnFromDate").value).value;// "2016-9-5"
if (fromDate != "") {
var d = fromDate.slice(0, 10).split('-');
if (d[1].length == 1)
d[1] = '0' + d[1];
if (d[2].length == 1)
d[2] = '0' + d[2];
fromDate = d[2] + '/' + d[1] + '/' + d[0]; // 05/09/2016
if (ValidateDates(fromDate, ToDate)) {
ShowMessage($("#hdnTodaeFromDateMessage").val());
selectedDate.setValue();
}
}
}
function ValidateDates(fromDate, ToDate) {
var flag = false;
var fromDatestr = fromDate;
var dt1 = fromDatestr.substring(0, 2);
var mon1 = fromDatestr.substring(3, 5);
var yr1 = fromDatestr.substring(6, 10);
var ToDatestr = ToDate;
var temp2 = "";
var dt2 = ToDatestr.substring(0, 2);
var mon2 = ToDatestr.substring(3, 5);
var yr2 = ToDatestr.substring(6, 10);
if (yr1 > yr2) {
flag = true;
}
if (yr1 == yr2 && mon1 > mon2) {
flag = true;
}
else if (yr1 == yr2 && mon1 == mon2 && dt1 > dt2) {
flag = true;
}
return flag;
}
C#代码
C# code
<igmisc:webasyncrefreshpanel id="warFromDate" runat="server" width="300%">
<igsch:webdatechooser id="wdcFromDate" runat="server" width="100px">
<clientsideevents valuechanged="GetFromDate">
<igmisc:webasyncrefreshpanel id="warToDate" runat="server" width="300%">
<igsch:webdatechooser id="wdcToDate" runat="server" width="100px">
<clientsideevents valuechanged="GetToDate">
推荐答案
C#代码
C# code
<igmisc:webasyncrefreshpanel id="warFromDate" runat="server" width="300%">
<igsch:webdatechooser id="wdcFromDate" runat="server" width="100px">
<clientsideevents valuechanged="GetFromDate">
<igmisc:webasyncrefreshpanel id="warToDate" runat="server" width="300%">
<igsch:webdatechooser id="wdcToDate" runat="server" width="100px">
<clientsideevents valuechanged="GetToDate">
这篇关于需要以javascript格式从“webdatechooser”获取日期“dd / MM / yyyy”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!