Reputation: 2109
I have a jsp file which contains:
<tr>
<td> End date </td>
<td> <div> <s:textfield name="endDate" label="End Date" value=""/> (dd/mm/yyyy - For Bid) </div> </td>
</tr>
Can someone tell me how to add a jquery datepicker which pops up the current month with today's date selected on selecting the text field
Upvotes: 1
Views: 4514
Reputation: 3457
Check this out jQuery UI DatePicker to show month year only it might help...
Upvotes: 1
Reputation: 5461
Use the following
jQuery("id").datepicker({
dateFormat:'MM YY',
onClose: function (dateText, inst) {
var month = jQuery("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year =jQuery("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).val(jQuery.datepicker.formatDate('yy-mm', new Date(year, month, 1)));
}
});
var myDate = new Date();
var prettyDate =(myDate.getMonth()+1) + ' ' +
myDate.getFullYear();
jQuery("id").val(prettyDate);
Hopes it may helps you
Upvotes: 1