1

I have a jsp file which contains:

<tr>
  <td> End date </td>
  <td>  <div> <s:textfield name="endDate" label="End Date" value=""/> &nbsp; (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

futurenext110
  • 1,991
  • 6
  • 26
  • 31

2 Answers2

1

Check this out jQuery UI DatePicker to show month year only it might help...

Community
  • 1
  • 1
sk8terboi87 ツ
  • 3,396
  • 3
  • 34
  • 45
1

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

muthu
  • 5,381
  • 2
  • 33
  • 41