Skip Navigation

[Resolved] limit date picket dates/times

This support ticket is created 5 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Ido Angel 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1254937

hey,
2 things:

1) i tried limiting the daye picker to only 3 years ahead from now, using this code:

  $( ".thedate" ).datepicker({
    minDate: 0,
    maxDate: 1095
  });

it worked, but i couldn't create an event anymore as no matter which date i chose, it gave a "this field is required" error.

2) is there a way to limit the minutes to 30 minutes intervals?

thx!

#1254943

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - have you added the date field as date filter to your views? If yes, can you please share problem URL?

2) is there a way to limit the minutes to 30 minutes intervals?
==> where and how exactly you want to display this section and where you want to use it?

#1254953

Hey minesh,
I'm using it in a cred form for creating and editing events with a date field.

#1254967

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok great - can you please share link where you added the form?

#1255001

Hey
It's here:

hidden link

Bit I removed the code. You can re add it, use the credentials from this thread here:

https://toolset.com/forums/topic/excerpt-from-custom-field-multilines-with-breaks/

You'll need them to see the page anyway..

Thx!

#1255023

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following code to your Form's JS box to restrict the datepicker maxdate to 3 years from now:

jQuery(window).load(function() {
  id = jQuery('input[name="wpcf-event-date[display-only]"').attr('id');
    jQuery( "#"+id ).datepicker("option","minDate","0");
    jQuery( "#"+id ).datepicker("option","maxDate","+3Y");
});   
#1255053

Hey
Thx but I tried now and it allowed me to place date before today and in 5 years...
Also - could you please take a look at the second question?
Thx!

#1255055

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thx but I tried now and it allowed me to place date before today and in 5 years...
=> Please clear your browser cache and check. I can not able to select past dates as well as the allowed date is 3 years from now, thats maxdate.

2) is there a way to limit the minutes to 30 minutes intervals?
==> No, there is no solution for this. At least I do not have it.

#1255091

ok - thx!
i checked on desktop - works.
but in mobiles, even if i delete cache, it still doesn't work.
maybe it's the windows.load function?
any other idea?
thx minesh!

#1255097

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I do not know about mobile compatibility.

What if you try to add the following code to your form's JS box, Please remove the existing code:

jQuery(window).bind("cred_form_ready", function() {
  
     id = jQuery('input[name="wpcf-event-date[display-only]"').attr('id');
    jQuery( "#"+id ).datepicker("option","minDate","0");
    jQuery( "#"+id ).datepicker("option","maxDate","+3Y");
 
});
#1255101

Perfect Minesh!!!!! Thanks so much. Now I need to find how to make those intervals... 🙂