Link to home
Start Free TrialLog in
Avatar of Cubbybulin
Cubbybulin

asked on

asp.net javascript datediff of 2 textbox dates

I have 2 textboxes that I want to enter dates into and a third textbox I want to automatically enter the number of days (datediff +1) difference of the 2 dates. I need to NOT have a postback for this and want to accomplish it in javascript. Would need it to evaluate if the text in the textboxes are actual dates (isdate()) and perform the calculation when leaving either textbox and fill in the third textbox with the number. Any help would be greatly appreciated!  
ASKER CERTIFIED SOLUTION
Avatar of Swapnil
Swapnil
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cubbybulin
Cubbybulin

ASKER

I am trying to use this solution from the link you provided. I am not sure how to invoke it though when a date is entered into either of the two textbox's (on textchanged) and then enter the value into the third textbox.

 <script type="text/javascript" src="date.js"></script>
       
<script type="text/javascript">                
var minutes = 1000*60;                
var hours = minutes*60;                
var days = hours*24;                  
var foo_date1 = getDateFromFormat("02/10/2009", "M/d/y");                
var foo_date2 = getDateFromFormat("02/12/2009", "M/d/y");                
var diff_date = Math.round((foo_date2 - foo_date1)/days);                
alert("Diff date is: " + diff_date );         </script>