<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$('#<%=Txt_Fromdate.ClientID%>').datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 2,
yearRange: "1900:+0",
showAnim: "slide",
dateFormat: "mm/dd/yy",
alt: "",
title: "",
onClose: function (selectedDate) {
$('#<%=Txt_Fromdate.ClientID%>').datepicker("option", "minDate", selectedDate);
}
});
$('#<%=Txt_Todate.ClientID%>').datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 2,
yearRange: "1900:+0",
showAnim: "slide",
dateFormat: "mm/dd/yy",
alt: "",
title: "",
onClose: function (selectedDate) {
$('#<%=Txt_Todate.ClientID%>').datepicker("option", "maxdate", selectedDate);
}
});
});
function ValidateDate() {
var errorCount = 0;
var todate = $('#<%=Txt_Todate.ClientID%>').val();
if (todate == "") {
$('#<%=Txt_Todate.ClientID%>').css("border-color", "red");
$('#<%=lblselectfromdate.ClientID%>').html("*");
errorCount++;
}
else {
$('#<%=Txt_Todate.ClientID%>').css("border-color", "");
$('#<%=lblselectfromdate.ClientID%>').html("");
}
var fromdate = $('#<%=Txt_Fromdate.ClientID%>').val();
if (fromdate == "") {
$('#<%=Txt_Fromdate.ClientID%>').css("border-color", "red");
$('#<%=lblselecttodate.ClientID%>').html("*");
errorCount++;
}
else {
$('#<%=Txt_Fromdate.ClientID%>').css("border-color", "");
$('#<%=lblselecttodate.ClientID%>').html("");
}
if (errorCount > 0) {
return false;
}
else {
return true;
}
}
</script>
<table class="auto-style1">
<tr>
<td class="auto-style3">FROM DATE</td>
<td class="auto-style2">
<asp:TextBox ID="Txt_Fromdate" runat="server"></asp:TextBox>
<asp:Label ID="lblselectfromdate" runat="server" ForeColor="Red"></asp:Label>
</td>
<td class="auto-style4">TODATE</td>
<td>
<asp:TextBox ID="Txt_Todate" runat="server"> </asp:TextBox>
<asp:Label ID="lblselecttodate" runat="server" ForeColor="Red"></asp:Label>
</td>
<td>
<td class="auto-style3">
<asp:Button ID="Btn_submit" runat="server" Text="SUBMIT" CssClass="actionbutton" OnClick="Btn_submit_Click" OnClientClick="return ValidateDate();" /></td>
</tr>
USE ABOVE CODE