Call a function when a input value is changes "not working"

Call a function when a input value is changes "not working"

Hi guys

I have 2 input fields which contains dates. I have created a function to do some math work when the second input is change.


here is what i have so far

  1.     <script type="text/javascript">

  2.     function calculateTotal(){
            var from =     $("#from").val();  //ex. 20-2-2013
            var to = $("#to").val();    //ex.25-2-2013
           
            // end - start returns difference in milliseconds
            var diff = new Date(to - from);
           
            // get days
            var days = diff/1000/60/60/24;  //ex.5
            var totalDays = Math.ceil(days);
       
            $("#totalDue").text("Total Days" + totalDays).addClass("subNotes");
        }
       
        $("#to").change(calculateTotal);














  3. </script>


what am i doing wrong? because the totalDue DIV does not change! it should display totalDays value!


Thanks