Skip Navigation

[Resolved] Disable past dates on date picker

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by leilaG 5 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#1352427

Hello,

I have tried the below code, but it's not working -

https://toolset.com/forums/topic/disable-the-past-date-on-datepicker/

( function( $ ) {
$( document ).ready( function(){
$('.js-wpt-date').datepicker( "option", "minDate", "0" );
});
})( jQuery );

#1352493
#1352499

Hi Leila,

I've tested the slightly different code snippet shared by Julie in the same thread that you've mentioned and it is working on your form, as expected.
( ref: https://toolset.com/forums/topic/disable-the-past-date-on-datepicker/#post-1086572 )

You can change the value "2030" to increase or decrease the allowed future date range, as required.
( screenshot: hidden link )

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1353635

Great! It's working. Thanks

Is there a place to put this code to make it site wide, or would we just need to add it to all forms individually?

#1353863

Hi Leila,

Thanks for the update and glad that it's working.

If you need to deploy different date picker requirements for different forms, it is better to include that script individually, in each form, so that it can be edited independently.

In case, the same script is needed for all cases site-wide, you can include it in the "Quick Javascript" field at WP Admin -> Appearance -> Theme Options.

Note: In this field, you'll need to wrap that code snippet in a script tag like this:


<script type="text/javascript">

actual code snippet

</script>

regards,
Waqar

#1353889

My issue is resolved now. Thanks Waqar!