Date Addition DatePicker on textbox Onblur event

2 posts, 0 answers
  1. Nandkishor
    Nandkishor avatar
    2 posts
    Member since:
    Aug 2012

    Posted 07 Mar 2012 Link to this post

     
    Hello,
    I have to set  date of DatePickerSelectLikelyDate to the date which is addition of selected in DatePickerLikelyDate and  txtTimeLag (no of days )

    but I am getting error that setDate is not supported function. I have used this function on OnBlur event of txtTimeLag.
     

    function SetLikelyDate(txtTimeLag) {

    var text = document.getElementById('<%=txtTimeLag.ClientID%>');

     

    var datePicker = $find("<%= DatePickerLikelyDate.ClientID %>");

    var datePickerSelectLikelydate = $find("<%= DatePickerSelectLikelyDate.ClientID %>");

    if (text != null) {

    var timelag = text.value;

    var currentdate = new Date(datePicker.get_selectedDate()).format("MM/dd/yyyy");

    alert(timelag);

    currentdate.setDate(currentdate.getDate() + timelag);

    datePickerSelectLikelydate.set_selectedDate(currentdate);

    alert(currentdate);

    }


    Please suggest.

    Thanks,
    Nandkishor.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Mar 2012 Link to this post

    Hello,

    Try the following.
    JS:
    <script type="text/javascript">
     function SetLikelyDate(txtTimeLag)
      {
       var text = document.getElementById("txtTimeLag");
       var datePicker = $find("<%= DatePickerLikelyDate.ClientID %>");
       var datePickerSelectLikelydate = $find("<%= DatePickerSelectLikelyDate.ClientID %>");
       if (text != null)
        {
         var timelag = parseInt(text.value);
         currentdate = new Date(datePicker.get_selectedDate());
         currentdate.setDate(currentdate.getDate() + timelag);
         datePickerSelectLikelydate.set_selectedDate(currentdate);
        }
      }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top