futurenext110
futurenext110

Reputation: 2109

Jquery: how to add a jquery datepicker in jsp

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

Upvotes: 1

Views: 4514

Answers (2)

sk8terboi87  ツ
sk8terboi87 ツ

Reputation: 3457

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

Upvotes: 1

muthu
muthu

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

Related Questions