Skip Navigation

[Resolved] Change default datepicker date in CRED

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

Problem:
Set dafault date [your_date] in a CRED date-picker

Solution:

You can change the default value of the Date-Field by passing a Unix Timestamp value as this example

[cred_field field="date" post="post" value="-1735689600" urlparam=""]

Ti chafe the Picker (calendar):
NOTE:
It sets a date range (2002/2012), with default date 01.01.2012

jQuery(window).bind("load", function() {
   jQuery( ".js-wpt-date" ).datepicker( "option", "yearRange", "2002:2012" ).datepicker("option", "defaultDate", "01012012");
});

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.

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by dinaraG 6 years, 4 months ago.

Assigned support staff: Beda.

Author
Posts
#311551

Hello!
I need to set dafault date 01.01.1915 in datepicker like this wp-types.com/forums/topic/set-default-datepicker-to-empty/ but in cred form.

#311658

Thank you for contacting us here in the Support Forum

I understand you have a Custom Field (date) and display it (use it) in a CRED Edit (or create) Form.

You can change the default value of that Field by passing a Unix Timestamp value as this example

[cred_field field="date" post="post" value="-1735689600" urlparam=""]

-1735689600 is the Unix Timestamp equivalent to 01/01/1915, 0.00 hrs.
hidden link

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you, I look forward to your reply!

Thank you

#311896

Now there is default date. But when I clicking datepicker icon the default date is today's date.

#311916

Well, assuming that you provide a certain CRED form, with the Date Field, you will have the preset date in this field (the value)

Now, if the user (who submits the form) needs to change that date, the DatePicker default to Today's date.

Let me speak to the DEV if it's possible to default as well the Date Picker to a certain Date

Please expect my informations here in the forum.

Thank you

#312213

You could try to use a Custom JS similar to this:

jQuery( ".wpv-date-front-end" ).datepicker( "option", "yearRange", "2002:2012" ).datepicker("option", "defaultDate", "01012012");

This will set the date to Jan 1, 2012. Mind the format: ddmmyy, meaning day on two cyphers, month on two cyphers, year on 4 cyphers.

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you, I look forward to your reply!

Thank you

#312616

I inserted this text to JavaScript textfield but it isn't working. Default date is still today's day and year range is 1583 - 3000.
My shortcode is
[cred_field field="data-vipuska" post="vipusk" required="true" value="-1735689600" urlparam=""]

#313502

Thanks for the Details

Yes, that's my mistake, as the CRED Date-picker has another pointer as Views, we should use .js-wpt-date-auxiliar instead of .wpv-date-front-end.

Therefore the JS Should look like:

jQuery( document ).ready(function() {
  var yearRange = jQuery( ".js-wpt-date-auxiliar" ).datepicker( "option", "yearRange" );
  jQuery( ".js-wpt-date-auxiliar" ).datepicker( "option", "yearRange", "2002:2012" ).datepicker("option", "defaultDate", "01012012");
});

(in order to default to 01.01.2012)

But It does unfortunately not produce the desired results.

I am consulting now the 2nd Tier Support to see where the issue is in.

Please expect my informations here in the forum.

Thank you

#313731

Please use the below JS, I tested it and it's correctly defaulting to 01.01.2012

jQuery(window).bind("load", function() {
   jQuery( ".js-wpt-date" ).datepicker( "option", "yearRange", "2002:2012" ).datepicker("option", "defaultDate", "01012012");
});

Please remember that you still need the custom Value, which I provided previously in this post, to also display the Date in the Date Text Field.

Please let me know if the above solution works for you, I look forward to your reply!

Thank you

#317340

Thank you! Now it is OK!