I have a datepicker in 2 textboxes , in am trying to add the value of these text boxes to a function that needs a valid Javascript Date.
This is the part of the function – start is a Date
else if (daystosearch == 'custom') {
start.setDate(Date.parse($('#<%= tStartDate.ClientID %>').val()));
end.setDate(Date.parse($('#<%= tEndDate.ClientID %>').val()));
}
Date.Parse will not work , because value of the textbox is “10/29/2012” which is not a parsable date. How can I use start.setDate and get the value of the textboxes date ?
If the value of the textbox is something like “10/29/2012”, you should be able to use:
But if you’re trying to use
setDate, the value that it accepts is an integer from 1-31, so you need to usegetDateon the new Date object, like: