Disable dates after current date Datapicker

Asked

Viewed 1,261 times

-1

I want to disable the dates after the current date on the Icker date. I know how to disable the previous dates with the line:

startDate: "date"

inserir a descrição da imagem aqui

However, as this Picker data would be for the Date of Birth field, I don’t think it is necessary for the dates after the current date to be enabled, only the previous ones. I understand that I could and will do the validation by programming, but if I could disable it would help a lot.

1 answer

1


I managed to fix it. I used logic. If startDate: "date" disables previous dates, then if I put:

endDate: "date",

It would disable later dates and that’s what happened:

inserir a descrição da imagem aqui

The code:

<div class="md-input-wrapper" id="sandbox-container">
    <input type="text" class="md-form-control">
    <label for="email">Data de Nascimento</label>
</div>
    <script>
        $('#sandbox-container input').datepicker({
            language: "pt-BR",
            format: "dd/mm/yyyy",
            endDate: "date",
            todayHighlight: true
        });
    </script>

Browser other questions tagged

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