Time limits using an advanced Time field [RESOLVED]

I’m wanting the time fields I’m creating to be limited to a certain time range (e.g. 9am-2pm), but I do not have a field in this form for a date picker, so I cannot use conditional logic from that.

Is there a way to have a stand alone time field have only a specific time available?

Thanks!

HI Walper. Can you create regular drop down fields which only offer the choices from 0900 to 1400, in whatever increments you need (like 15 minutes?) That would give you drop downs rather that number inputs. If you want to use the built in time field number inputs, you could use the gform_field_validation filter to ensure that the time is between 0900 and 1400. We have an example of how to restrict the entered time to business hours between 0900 and 1700, here:

If you have any other questions, please let us know.

Hey Chris!
Thanks for that response. I’m thinking that code might work. Any idea where I might insert it into Wordpress? I’m new to coding!

Thanks a lot!

Hi Walper. The gform_field_validation filter is a PHP filter, and PHP code can go into your theme functions.php file, or you can use a plugin like this to keep the code separate from the theme:

We have a little additional information here:

GravityWiz also has an article, if you run into any trouble:

Thank you!!

1 Like