• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Limit Date Picker to third saturday of the month

Limit Date Picker to third saturday of the month 1 year 2 months ago #42553

I have managed to limit dates to Saturdays at 2:00pm only using the following:
<script type="text/javascript">
jQuery(document).ready(function(){
  myDateTPicker = RSFormPro.jQueryCalendar.calendars[16]['BaptismDate'];
  //replace 25 with your form ID and the date time picker name.
  myDateTPicker.callbackSelectedDateTime = function(selectedDateObject, calendarInstance, calendarDateObject, input, inputFormat) {
    weekDay = calendarDateObject.getDay();
    if(weekDay == 0 || weekDay == 1 || weekDay == 2 || weekDay == 3 || weekDay == 4 || weekDay == 5){
    //0 = Sunday, 1 = Monday and so on...
      alert('Currently Baptisms are only offered on a Saturday. Please select a Saturday.');
      return false;
    }
  }
});
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
  myDateTPicker = RSFormPro.jQueryCalendar.calendars[16]['BaptismDate'];
  //replace 17 with your form ID and the date time picker name.
  myDateTPicker.calendarInstance.setOptions({
    datepicker:true,
    timepicker:false,
    allowTimes:['14:00'],
  });
});
</script>

However I now need to restrict dates to only 2:00pm on the third Saturday of any month in the future.

It would also be handy not to bother showing the 2:00pm time on the date picker
The administrator has disabled public write access.

Limit Date Picker to third saturday of the month 1 year 2 months ago #42554

I have downloaded the Advanced Form Fields and tried the Date Picker there.

It has a really handy way of greying out all days except Saturdays (which is better than the standard DatePicker) - however I still wish to restrict dates to the third Saturday of the Month.
The administrator has disabled public write access.

Limit Date Picker to third saturday of the month 1 year 2 months ago #42555

I figured it out (with help from a friend)

To only allow the third saturday in the month to be selected...

In the Date and Time Picker go to Attributes tab

In the Allowed Dates (m/d/Y) place the following PHP code
//<code>
	$dateTime	= new DateTime();
	$dateEnd	= new DateTime("+2 year");
	$dates = '';
	while ($dateTime < $dateEnd) {
    	$dates .= date('m/d/Y', strtotime('third saturday of '.$dateTime->format('F Y'))) . "\n";
    	$dateTime->modify('+1 month');
	};
	return $dates;
//</code>

Tip:
You can of course increas the number of Years if you want more than 2 years
and change 'third saturday of ' to 'first monday of ' if you want
Last Edit: 1 year 2 months ago by denis.r.oregan. Reason: Extra tip
The administrator has disabled public write access.
The following user(s) said Thank You: gws
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!