Problems with DATEPICKER, using only month and year

Asked

Viewed 708 times

1

Good afternoon, you guys I have a little problem in my plugin datepicker I’m only using month and year in it, and when selecting a month and a year, the month instead of coming in number, for example 02, which means, February, it comes in string, and in English still. How can I solve this problem? Below is the code:

--- IN MY HTML IS THAT JS: ---

<script>
    $(function () {
        $('.date-picker').datepicker({
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true,
                dateFormat: 'MM yy',
                onClose: function (dateText, inst) {
                                var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                                var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                                $(this).datepicker('setDate', new Date(year, month, 1));
                                }
        });
    });
</script>

--- WHERE I WANT THE DATEPICKER TO APPEAR ---

<p><label for="startDate">Data:</label></p>
            <p><input name="startDate" id="startDate" class="date-picker" type="data" name="parametro3" id="calendario" value="Ex.: 30/05/2010" onBlur="if(this.value=='')this.value='Ex.: 30/05/2010'" onFocus="if(this.value=='Ex.: 30/05/2010')this.value=''"></p>

--- IN MY CSS ---

.ui-datepicker-calendar {
display: none;
}

This solution, I found right here in the forum Thank you for your patience Thank you

  • In the documentation of datepicker they must indicate the possible formats. Try to change MM by mm (minuscule).

  • Thank you Joao, I managed to solve!!

  • If possible put the answer here to help others.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.