I am using this date picker from jqueryui .
If you look at this page, you will find that they are just written by one function:
$(function() { $("#datepicker").datepicker(); }); </script>
But I want to open my date picker in one click event of a text field.
So I wrote this:
$("#datepicker").datepicker();
in one function that I call in the onclick event text box.
But this raises one problem.
I only get the date picker the second time I click on the text box.
If I click the first time after loading the page, then the date selection will not appear, but as soon as I click the second time, then the date selection will come.
<b> Why? And can I do this on the first click?
Yes, I know this already happens fine if I put the first code, but I want it in my function.
EDIT:
Now I will explain to all of you guys exactly what I am doing. My requirement is this:
1) When I choose a date for the first time. Dates until today should be disabled on the calendar.
2) Now, when I select a date a second time on the calendar, the date should start one day after the previous date. I wrote like this ....
$(function() { $('#from').datepicker({ defaultDate: "+5d", changeMonth: true, numberOfMonths:1 , minDate:"+0d", dateFormat: 'DD, MM d, yy', onSelect: function(selectedDate) { var option = this.id == "from" ? "minDate" : "maxDate"; var instance = $(this).data("datepicker"); var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings); dates.not(this).datepicker("option", option, date); } }); });
This works fine for one requirement, but for the second requirement I need to first check if there is a text field value. If there is any, then
he must choose direct +1 for this date, and previous dates should be disabled.
How to do it?
jquery jquery-ui datepicker
Nitz
source share