Calendar is not storing the recorded date.

  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1756
  • Karma: 62
  • Thank you received: 218

mihaela replied the topic: Calendar is not storing the recorded date.

Hello again,

I see now how you want this to work.

To achieve what you want do as follows.
Go to form's Advanced properties > Form pieces and in Before Form section set Type to Custom. In the code area below put the following code:
echo '<script type="text/javascript">
                                        
    JQuery(document).ready(function () {
                             
        JQuery("#ff_elem26793_calendarButton").pickadate({
			format: "yyyy-mm-dd", 
                        selectMonths: true,
                        selectYears: true,
                        min: true,
                        editable: true,
                        firstDay: 1,
			onSet: function() {JQuery("#ff_elem26793").val(this.get("value"));
ff_getElementByName("cal2").value = ff_getElementByName("cal").value; }
		});
        });
</script>';
NOTE: In the code above replace ff_elem26793 with the ID of first calendar element for "check in". Also, replace ff_elem26793_calendarButton with the ID of it's button.
Furthermore, replace cal2 with the Name of 2nd calendar field and cal with the Name of first calendar field from which value should be copied.

That should do the trick.
Also, I've added functionality that users aren't able to select date in the past (since this is "check in" date).
If you want to remove that functionality, just remove this line from the script above:
min: true,

Don't forget to remove the previous Initialization script.

Let me know whether this works as you wanted.

Regards,

Mihaela
#232248
  • tyekynan
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1

tyekynan replied the topic: Calendar is not storing the recorded date.

This does copy the date into the field and allows me to change it. However,

I choose 2019-02-13 on cal one.

It populates 2019-02-13 into the calendar two field, but when I click the calendar button to pull up the calendar it reverts the calendar back to todays date.
#232578
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1756
  • Karma: 62
  • Thank you received: 218

mihaela replied the topic: Calendar is not storing the recorded date.

Hello,

You are right, this will fill in the calendar field, but when clicking on in the pop-up calendar today's date will be selected.
Pre-selecting a date in responsive calendar is a bit more complicated.

Therefore I suggest that you use a different approach. Also, I think that the following solution is better to oblige the user to select check out date after the check in date.

So remove the code previously suggested and go to Properties of the second calendar element.
In the Validation section check the Required checkbox and set the Validation type to Custom.
In the code area below put the following code:
function ff_cal2_validation(element, message)
{
    if (element.value == "" ) {
        if (message=='') message = "Fill in the checkout date.\n"
        ff_validationFocus(element.name);
        return message;
    } // if

     if (element.value.split("-").length != 3 ) {
        if (message=='') message = "Fill in the checkout date in format yyyy-mm-dd .\n"
        ff_validationFocus(element.name);
        return message;
    } // if
   
   var Date1 = Date.parse(ff_getElementByName("cal").value); 

    var Date2 = Date.parse(element.value); 
    if ( Date1 >= Date2) {
        if (message=='') message = "Check out date must be after check in date.\n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';
} // ff_cal2_validation
NOTE: In the code above replace every instance of cal2 with the Name of the second calendar element and cal with the Name of the first calendar element.

Let me know whether this resolves the issue.

Regards,

Mihaela
#232597
Moderators: ForumSupporttomeperica
Time to create page: 0.062 seconds

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

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€

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!

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