× Form Help

Check-In and Check-Out Responsive Calendar

  • tyekynan
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 53
  • Thank you received: 2

tyekynan created the topic: Check-In and Check-Out Responsive Calendar

I have 2 responsive calendar fields:

Check-In

Check-Out


When someone clicks the button to bring up the Check-In responsive calendar and chooses a date. For example, 3/14/2020.

I would like the Check-Out responsive calendar to disable all dates from 3/14/2020 and earlier. Or at least default to the day after. I have searched and searched for a fix to this to no avail. Thanks in advance.

Here is an example: codepen.io/amandalouise/pen/PNzeGx
#238316
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2738
  • Karma: 93
  • Thank you received: 369

mihaela replied the topic: Check-In and Check-Out Responsive Calendar

Hello,

You can try to use this solution crosstec.org/en/forums/15-usage/116892-d...nd-after.html#201745 which will work what you want. Put the suggested code in the initialization script.
In order for that example to work, the names of the responsive calendar have to be "arrival" and "departure".

Note that in that case, the calendar will look a bit different. You will see how it looks when you test it.
This way the person filling in the form won't be able to select a departure date before the arrival date

The other option would be to add validation to the calendar element so that, when clicking on the submit button, if the departure date is not after the arrival date an error message will appear. User will have to change that in order to be able to submit the form.
Here you can take a look at an example code for a validation code crosstec.org/en/forums/1-forums/125424-c....html?start=6#232597 .

Let me know whether this helped and whether you have managed to set it for your form.

Regards,

Mihaela
#238325
  • tyekynan
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 53
  • Thank you received: 2

tyekynan replied the topic: Check-In and Check-Out Responsive Calendar

This works for responsive calendars. Let's say the first calendar has the name "arrival" and the second "departure". Use this code in form > Advanced tab > More options > Scripts > Initialization script > Type > check Custom:

function ff_pickdate_arrival_departure_init()
{

 jQuery('.bfCalendar').remove();
    
   jQuery('[name="ff_nm_arrival[]"]').pickadate({
 min: true
})


var from_$input = jQuery('[name="ff_nm_arrival[]"]').pickadate(),
    from_picker = from_$input.pickadate('picker')

var to_$input = jQuery('[name="ff_nm_departure[]"]').pickadate(),
    to_picker = to_$input.pickadate('picker')


// Check if there’s a “from” or “to” date to start with.
if ( from_picker.get('value') ) {
  to_picker.set('min', from_picker.get('select'))
}
if ( to_picker.get('value') ) {
  from_picker.set('max', to_picker.get('select'))
}

// When something is selected, update the “from” and “to” limits.
from_picker.on('set', function(event) {
  if ( event.select ) {
    to_picker.set('min', from_picker.get('select'))    
  }
  else if ( 'clear' in event ) {
    to_picker.set('min', false)
  }
})
to_picker.on('set', function(event) {
  if ( event.select ) {
    from_picker.set('max', to_picker.get('select'))
  }
  else if ( 'clear' in event ) {
    from_picker.set('max', false)
  }
})
}
In the first line:
function ff_pickdate_arrival_departure_init()
replace "pickdate_arrival_departure" with the name of your form.


This works beautifully. One more question though. The date shows as 28 May, 2019... how can I change this to either May 28 2019 or just mm/dd/yyyy?
#238332
Moderators: ForumSupporttomeperica
Time to create page: 0.054 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here