Hi, I have created a date/time custom field with Toolset.
How can I restrict the datepick input to a date/time before "now"?
Thanks.
Hello and thank you for contacting the Toolset support.
The datepicker is from jQuery UI. You can use the maxDate option on it hidden link
Listen for the form's ready event, and apply the maxDate. Something like this should work:
jQuery(document).on('cred_form_ready', function() {
jQuery( ".js-wpt-date" ).datepicker({
maxDate: 0
});
});
The forum has several threads about the datepicker customization. Maybe they may help:
hidden link
I assumed that you are talking about a Toolset form. Let me know if it is not the case.
Hi Jamal,
Thanks for the tip.
I was talking about a Toolset custom field on backend, assigned to WooCommerce orders.
Use the browser developer tools to get the name, id, or class of the field in the backend. Then use a plugin or custom code to add your Javascript code to the backend. https://wordpress.org/plugins/code-snippets/
Read more about jQuery selector here hidden link
Rely on the "ready" event:
jQuery(document).on('ready', function() {
var selector = ".js-wpt-date"; // get the selector using the browser developer tools
jQuery( selector ).datepicker({
maxDate: 0
});
});
I hope this helps. Let me know if you have any questions.
Hi Jamal,
I would need some help here, as I cannot get it work.
Would you be so kind to check this link and tell me which selector id I should use for the datepicker?
hidden link
Thanks.
Of course. Would you allow me temporary access to your website to check it closely? I tried to figure it out from my side, but I'll need to access the backend to better handle it. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
My issue is resolved now. Thank you!