This is a migrated thread and some comments may be shown as answers.

Date Addition DatePicker on textbox Onblur event

1 Answer 255 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Nandkishor
Top achievements
Rank 1
Nandkishor asked on 07 Mar 2012, 07:05 AM

 
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.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Mar 2012, 10:44 AM
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.
Tags
Calendar
Asked by
Nandkishor
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or