My code is supposed to subtract dates (enddate-startdate) but nothing's happening and can't figure out where the problem is.
<script type="text/javascript">
function subtractDate()
{
var sDate = Date.parse("<%=txtStartDate.Text%>");
var eDate = Date.parse("<%=txtEndDate.Text%>");
var resultDate = document.getElementById("<%=txtnumberOfDaysCovered.ClientID%>")
if (document.getElementById(sDate) < document.getElementById(eDate)) {
var timeDiff = eDate.Subtract(sDate);
resultDate = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
}
}
</script>
I already tried to call it behind
protected void txtStartDate_TextChanged(object sender, EventArgs e)
{
// SubtractDateStartDateChange();
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "subtractDate(this.Id)", true);
}
protected void txtEndDate_TextChanged(object sender, EventArgs e)
{
//SubtractDate();
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "subtractDate(this.Id)", true);
}