# Prevent Selection in Dropdown if \< 24 hours away from current time

**URL:** <https://forums.knack.com/t/prevent-selection-in-dropdown-if-24-hours-away-from-current-time/17493>\
**Category:** Ask Developers\
**Created:** [July 1, 2024, 6:22pm UTC](https://forums.knack.com/t/prevent-selection-in-dropdown-if-24-hours-away-from-current-time/17493 "2024-07-01T18:22:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quynh-Tram](https://avatars.discourse-cdn.com/v4/letter/q/e9c0ed/32.png) [@Quynh-Tram](https://forums.knack.com/u/Quynh-Tram)\
**Post date:** [July 1, 2024, 6:22pm UTC](https://forums.knack.com/t/prevent-selection-in-dropdown-if-24-hours-away-from-current-time/17493/1 "2024-07-01T18:22:02Z")

</div>

How can I prevent a user from selecting or submitting an event from the dropdown menu of a field in a form if the date/time is less than 24 hours away from the current time?

---

<div class="post-metadata">

**Author:** ![Les](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/les/32/4243_2.png) [@Les](https://forums.knack.com/u/Les)\
**Post date:** [July 1, 2024, 6:43pm UTC](https://forums.knack.com/t/prevent-selection-in-dropdown-if-24-hours-away-from-current-time/17493/2 "2024-07-01T18:43:52Z")

</div>

Hi @Quynh-Tram,

Good question!

You can add a [validation rule](https://learn.knack.com/article/1isca4mrri-validation-rules) to the date/time field that is in your form view. Your validation rule could look like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/b/b8b2b7fafc0a4ac8321340cc8244a82bf447e987.png)

You also could add instructions to your date/time input field in your form like this (won’t prevent them from submitting, but it will give them the message before they submit):

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/d/d6e6311cbb8059e0638e223c5af1b3244128c3f1.png)

I hope this helps, and thank you for sharing your question!

---

<div class="post-metadata">

**Author:** ![Quynh-Tram](https://avatars.discourse-cdn.com/v4/letter/q/e9c0ed/32.png) [@Quynh-Tram](https://forums.knack.com/u/Quynh-Tram)\
**Post date:** [July 1, 2024, 6:55pm UTC](https://forums.knack.com/t/prevent-selection-in-dropdown-if-24-hours-away-from-current-time/17493/3 "2024-07-01T18:55:45Z")

</div>

Hi Leslie,

I forgot to mention that the event is a connection to another table, and I would like to reference the date/time in the “Event” table but the field/form being used is in the second table.

Basically, the events are in a dropdown for users to register to one, but if the event is less than 24 hours away, I want to prevent submission

---

<div class="post-metadata">

**Author:** ![Les](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/les/32/4243_2.png) [@Les](https://forums.knack.com/u/Les)\
**Post date:** [July 1, 2024, 7:29pm UTC](https://forums.knack.com/t/prevent-selection-in-dropdown-if-24-hours-away-from-current-time/17493/4 "2024-07-01T19:29:52Z")

</div>

Oh I see, thank you for additional info!

For connection dropdown field inputs in forms, you can add filters for which records are available for your users to choose from:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/d/d3dfd10fce366dc037ad00ea40d8c0f3300364e3.png)

Since my example filter is set for “is after today” the filtered event dates available in the Live App form are in the future:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/8/8dab103d90bb099d99211ee19f6d178c9feab342.png)

You will also want to ensure that the data table the connection field exists in has the display field in the [table settings](https://learn.knack.com/article/table-settings#display_field) set for the date/time field:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/6/602475159975ed2233afadf35fe1b5c658b2eb02.png)

If this doesn’t help, please feel free to reach out to our support team and they will be happy to take a look at your app and help you further. You can reach out to them via this form: [Create Support Ticket](https://learn.knack.com/article/kb-tickets/new)
