1

I have a datepicker that displays months and years.. months in literal form (March, April etc).

When I click on the date picker and the value in my text field is "march 2014" the datepicker displays the current month (june) instead. The datepicker cant parse the date in that literal format. I'm trying to reverse parse it before the datepicker shows.. but its not working. for example:

var monthSelect = $('#monthSelect').datepicker({
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: 'MM yy',
    beforeShow: function(){
        var months = { 'January' : '01', 'February' : '02', 'March' : '03', 'April' : '04', 'May' : '05', 'June' : '06', 'July' : '07', 'August' : '08', 'September' : '09', 'October' : '10', 'November' : '11', 'December' : '12'};
        var thisval = $(this).val().split(' ');
        var numericMonth = months[thisval[0]];
        var numericYear = thisval[1];
        $(this).datepicker('setDate', numericMonth + '/01/' + numericYear);
        // $(this).val(numericMonth + '/01/' + numericYear);        
    },

Is there any way to "unformat" the date? I'm sure there must be but I just cant seem to find the correct way

look at this fiddle.. can anyone get the date to stick?

http://jsfiddle.net/W9B3L/

hamobi
  • 7,940
  • 4
  • 35
  • 64
  • Strange, this question which is very similar (http://stackoverflow.com/questions/2208480/jquery-ui-datepicker-to-show-month-year-only) has an answer that doesn't work either. Must be a some quirk/bug in the datepicker. – j08691 Jun 02 '14 at 19:57

0 Answers0