Hello Sir,
I' trying to compare the 2 dates in javascript.
Validating the End date should be greater than the start date
Below is the code.
<div class="form-group">
<label>Start Date </label>
<asp:TextBox ID="start_date" class="form-control Datepicker " placeholder="Enter Date" runat="server"></asp:TextBox>
<Ajax:CalendarExtender ID="CalendarExtender5" runat="server"
TargetControlID="start_date" CssClass="" Format="dd/MM/yyyy"
Enabled="True"
PopupButtonID="start_date" />
</div>
<div class="form-group">
<label>End Date </label>
<asp:TextBox ID="End_date" class="form-control Datepicker " placeholder="Enter Date" runat="server"></asp:TextBox>
<Ajax:CalendarExtender ID="CalendarExtender5" runat="server"
TargetControlID="End_date" CssClass="" Format="dd/MM/yyyy"
Enabled="True"
PopupButtonID="End_date" />
</div>
<script type="text/javascript">
function Update() {
var fv50 = document.getElementById('<%=start_date.ClientID%>').value;
var fv52 = document.getElementById('<%=End_enddate.ClientID%>').value;
else if ((fromDate != "" && toDate != "") && Date.parse(fromDate) > Date.parse(toDate)) {
alert("To date should be greater than From date.");
return false;
}
else {
swal({
title: "Are you sure?",
text: "You want to Update!",
type: "warning", showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, Update it!",
cancelButtonText: "No, Cancel Please!",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
swal({
title: 'Updated!',
text: 'Your record has been Updated.',
type: 'success'
}, function () {
document.getElementById('<%=hidUpdate.ClientID%>').value = "Update";
document.forms[0].submit();
});
} else {
swal("Cancelled", "Your record is safe :)", "error");
}
});
}
}
</script>
Please help
Thanks