var txtFromDate = document.getElementById('<%= txtDueFromDate.ClientID %>');
var txtToDate = document.getElementById('<%= txtDueToDate.ClientID %>');
if (txtFromDate.value.trim() == '') {
divDueDateSearch.innerHTML = '*Enter From Date!';
divDueDateSearch.style.display = 'block';
txtFromDate.focus();
return false;
}
if (txtFromDate.value.trim() != '' && txtFromDate.value.trim() != '__/__/__') {
if (!isDate(txtFromDate.value.trim())) {
divDueDateSearch.innerHTML = '*Enter Valid Date!';
divDueDateSearch.style.display = 'block';
txtFromDate.focus();
return false;
}
}
if (txtToDate.value.trim() == '') {
divDueDateSearch.innerHTML = '*Enter To Date!';
divDueDateSearch.style.display = 'block';
txtToDate.focus();
return false;
}
if (txtToDate.value.trim() != '' && txtToDate.value.trim() != '__/__/__') {
if (!isDate(txtToDate.value.trim())) {
divDueDateSearch.innerHTML = '*Enter Valid Date!';
divDueDateSearch.style.display = 'block';
txtToDate.focus();
return false;
}
}
var Date1 = new Date(txtFromDate.value.trim());
var Date2 = new Date(txtToDate.value.trim());
if (Date2 < Date1) {
divDueDateSearch.innerHTML = '*To Date should be greater than From Date!';
divDueDateSearch.style.display = 'block';
txtToDate.focus();
return false;
}
else if (Date2 >= Date1) {
return true;
}
<asp:Panel ID="pnlCustomDate" runat="server" Enabled="false">
<span>From Date: </span>
<asp:TextBox ID="txtFromDate" runat="server" Width="120px"></asp:TextBox>
<asp:ImageButton runat="Server" ID="imgFromDate" ImageUrl="~/images/Calendar.gif"
ImageAlign="AbsMiddle" AlternateText="cal" />
<ajaxToolkit:CalendarExtender ID="ceSearch" runat="server" TargetControlID="txtFromDate"
CssClass="MyCalendar" Format="MM/dd/yy" PopupPosition="TopLeft" PopupButtonID="imgFromDate" />
<ajaxToolkit:MaskedEditExtender ID="meeSearch" runat="server" Mask="99/99/99" CultureName="en-US"
MaskType="Date" TargetControlID="txtFromDate" PromptCharacter="_">
</ajaxToolkit:MaskedEditExtender>
<span>To Date: </span>
<asp:TextBox ID="txtToDate" runat="server" Width="120px"></asp:TextBox>
<asp:ImageButton runat="Server" ID="imgToDate" ImageUrl="~/images/Calendar.gif" ImageAlign="AbsMiddle"
AlternateText="cal" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtToDate"
CssClass="MyCalendar" Format="MM/dd/yy" PopupPosition="TopLeft" PopupButtonID="imgToDate" />
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" Mask="99/99/99"
CultureName="en-US" MaskType="Date" TargetControlID="txtToDate" PromptCharacter="_">
</ajaxToolkit:MaskedEditExtender>
</asp:Panel>
No comments:
Post a Comment