Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Prevent picking dates that are outside of the set start and end dates in DateChooser


    I have a DateItem with a startDate and endDate but when you use the DateChooser, you are able to select a date before the start date or after the end date. For example, if your end date is December 31, 2027 - you just need to get your DateChooser to that month and year, then click on a January date. It will be able to select that date and you will even able to move the months with the navigation arrows through the next year.

    Screenshots below of it happening in the SmartGWT showcase.

    Selecting Jan 8th 2028 even though max date should be December 31 2027:

    Click image for larger version

Name:	select_past_end_date.png
Views:	105
Size:	44.0 KB
ID:	268249
    Jan 8 2028 selected and now you can keep going through 2028.
    Click image for larger version

Name:	after_select_past_end_date.png
Views:	76
Size:	43.5 KB
ID:	268250

    #2
    Please be sure to read the docs for the properties you use, e.g. DateItem.startDate:

    Minimum date the selectors will allow the user to pick. The default value is January 1st, 10 years before the current year.

    NOTE: by design, setting startDate and endDate will not always prevent the user from picking invalid values. In particular:
    • the set of available days will only be restricted if the start and end dates fall within the same month
    • the set of available months will only be restricted if the start and end dates fall within the same year

    This is by design as it allows the user to set the day, month and year in whatever order is convenient, rather than forcing them to pick in a specific order.

    For actual enforcement of a date being in correct range before data is submitted, a Validator of type "dateRange" should always be declared.

    Comment


      #3
      Thanks, I did see that but was still hoping there would be a way to not have that. I have a date range validator but it would be preferable to not allow the user to even be able to click on dates outside of the set range. I think there should at least be that option allowed. If there is nothing I can do about it then I will just rely on the validator or only have a dropdown.

      Comment

      Working...
      X