22
Views
7
Comments
In iOS, how can I restrict the date in a standard date picker based on another select
Application Type
Mobile

I am using a standard date picker with min and max attributes to restrict the date selection. It works fine on web and Android, but it doesn't work as expected on iOS. Can you suggest a solution? 

2026-03-12 10-32-06
Wahaj Adil

hi @GOKULPRASANTH MUNUSAMY , hope you're doing well.

iOS may ignore the min/max attributes at selection time.
Try using an OnChange action on the input date, in the logics compare selcted date with allowed range. If it is outside show a message and reset the value.

If selected_date < min_date or selected_date > max_date: 
showMessage ("Please select a valid date.") and reset date input.


hope this helps, let me know if u need more info.


thanks and regards!

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY

Thanks for your reply @Wahaj Adil 

But I need to disable the Dates in the  picker.


Regards,

Gokulprasanth M

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY
2025-03-12 07-08-15
Nilesh Trivedi


Use JavaScript Validation on Change

<script>
  const input = document.getElementById("myDate");
  const minDate = new Date("2024-01-01");
  const maxDate = new Date("2025-12-31");

  input.addEventListener("change", function () {
    const selectedDate = new Date(this.value);
    if (selectedDate < minDate || selectedDate > maxDate) {
      alert("Date is out of allowed range!");
      this.value = ""; // or reset to min/max
    }
  });
</script> 

Thank You

2026-03-12 10-32-06
Wahaj Adil
2019-01-07 16-04-16
Siya
 
MVP

@GOKULPRASANTH MUNUSAMY : Please try DatePickerDisableDays or DatePickerDisableWeekDays from OutSystemsUI to disable Days / WeekDays.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.