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?