Showing just one day on Datapicker

Asked

Viewed 241 times

1

I have 2 datapickers, as I do to show only that day I stored?

code:

$("#data-retorno").datepicker({
                dateFormat: 'dd/mm/yy',
                dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
                dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
                dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
                monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
                monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
                beforeShowDay: function (date) {
                    return [date.getDay() == 5, ""]
                },
                onClose: function(selectedDate) {
                   var data = $.datepicker.parseDate('dd/mm/yy', selectedDate);
                   data.setDate(data.getDate('dd/mm/yy') + 1);
                   alert(data);
                   $("#data-checkout").datepicker("option", "minDate", data);  
                }
            });

In the case in this script, the date selected, it will add up to 1 day,now, as if return only that day in the script below?

$("#data-checkout").datepicker({
                dateFormat: 'dd/mm/yy',
                dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
                dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
                dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
                monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
                monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
                beforeShowDay: function (date) {
                    return [date.getDay() == 6, ""]
                }
            });
        });
  • 1

    Sorry, I don’t understand your doubt...

  • In this variable var data = $.datepicker.parseDate('dd/mm/yy', selectedDate); I store a selected day. And I pass this value to datapicker #data-checkout, only in it, I Seto minDate, causing, return Saturdays from that date, only that I do not want you to return from the date, I want to return only the date. If the guy clicks 14 will add up + 1 getting 15; I do not want him to return from 15, and yes, only the 15.

  • 1

    Try to inform the minDate and maxDate equal. That is, the two with the same date, in your example it would be the day 15. In your case, it would be only add maxDate in onClose: $("#data-checkout").datepicker("option", "maxDate", data);

  • Thanks ! worked out !

No answers

Browser other questions tagged

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