Skip Navigation

[Resolved] Date picker restriction

This thread is resolved. Here is a description of the problem and solution.

Problem:

How to restrict the datepicker of range in Toolset Forms?

Solution:

It needs custom JS codes, for example:

https://toolset.com/forums/topic/date-picker-restriction/#post-2195603

Relevant Documentation:

This support ticket is created 2 years, 6 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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by philipC-4 2 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2194303

I am trying to restrict the date that can be picked to the following
- If the date is on or before the 6th day of the month, the date can be from the following month up to the current day
- If the date is after the 6th day of the month, the date can only be select from the current month up to the current day

I have the following but it is not working

<script>
$(function() {
$( "#datepicker" ).datepicker({ minDate: "-1M + 6D", maxDate: 0 });
$( "#datepicker" ).datepicker({ minDate: 0M, maxDate: 30D });
});
</script>

#2194511

Hello,

I assume we are talking about post forms created with Toolset Forms plugin, if it is, you need to use "cred_form_ready" to trigger you custom JS codes, for example:

jQuery(document).on('cred_form_ready', function() {
// here setup your custom JS codes
jQuery( "#datepicker" ).datepicker({ minDate: "-1M + 6D", maxDate: 0 });
jQuery( "#datepicker" ).datepicker({ minDate: 0M, maxDate: 30D });
 });
#2195221

Thank you for the guidance. I have modified my code to the following and it still has no effect on restricting the field. It works in a fiddle, what am I missing?

jQuery(document).on('cred_form_ready', function() {

jQuery( "#cred_form_365_1_1_time-entry-datedatepicker" ).datepicker({
minDate: "-1M",
maxDate: "0"
});

});

Thank you!

#2195529

Since it is a custom JS codes problem, please provide a test site with the same problem, fill below private message box with login details, also point out the problem page URL and form URL, I need to test and debug it in a live website.

#2195603

Thanks for the details, I have modified the custom JS codes in your website as below.

jQuery(document).on('cred_form_ready', function(){
    jQuery("[name='wpcf-time-entry-date[display-only]']").each(function() {
        jQuery(this).datepicker("option", "minDate", "-1M").datepicker("option", "maxDate", "0");
    });
});

please test again, check if it is what you want:

#2195973

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.