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>
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 });
});
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!
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.
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:
My issue is resolved now. Thank you!