Michael
Michael

Reputation: 33297

How to set the maximum Date to today in GWT 2.6 DatePicker?

I want to use a GWT 2.6 DatePicker with month and year selector:

datePicker.setYearAndMonthDropdownVisible(true);
datePicker.setYearArrowsVisible(true);

Is there a way to set the maximal date a user can select to today?

enter image description here

Upvotes: 0

Views: 755

Answers (2)

suprasad
suprasad

Reputation: 1513

Below is a link to a simple example that shows how to disable dates past a particular end date. May be you can use this concept and build on it to fit your requirements:

http://c.gwt-examples.com/home/ui/datepicker

Upvotes: 1

Andrei Volgin
Andrei Volgin

Reputation: 41089

You cannot set the maximum date to the current date. You can implement this functionality yourself, but you will quickly realize that it involves a lot of work and some difficult UI decisions.

Your users are not stupid, so they typically won't try to enter a future date in a field where it makes no sense. One in a few thousand users may do it by mistake. Is it worth your time to program for this rare mistake? I believe that a simple validation with an error message, when necessary, is sufficient for this use case.

Upvotes: 1

Related Questions