TOPIC:

Responsive Calendar - Date Format and Disable Past Dates 4 years 11 months ago #203355

  • Topic Author
  • rcaragao
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 0
Hi!

I'm using the following code to set MM-DD-YYYY as date format:
function ff_00N1a000006liih_validation(element, message)
{
   // Regular expression used to check if date is in correct format
   var pattern = /(0|1)[0-9]\-[0-3][0-9]\-(19|20)[0-9]{2}/;
   if(pattern.test(element.value))
   {
      var date_array = element.value.split('-');
      var month = date_array[0] - 1;

      // Attention! Javascript consider months in the range 0 - 11
      var day = date_array[1] ;
      var year = date_array[2];

      // This instruction will create a date object
      source_date = new Date(year,month,day);

      if(year != source_date.getFullYear())
      {
         return message == '' ? 'Element ' + element.name + ' failed my test' : message;
      }

      if(month != source_date.getMonth())
      {
         return message == '' ? 'Element ' + element.name + ' failed my test' : message;
      }

      if(day != source_date.getDate())
      {
         return message == '' ? 'Element ' + element.name + ' failed my test' : message;
      }
   }
   else
   {
      return message == '' ? 'Element ' + element.name + ' failed my test' : message;
   }

   return '';
}

To disable past dates, I'm using the following:
echo '<script type="text/javascript">
                                        
    JQuery(document).ready(function () {
                          
        JQuery("#ff_elem44_calendarButton").pickadate({
			format: "mm-dd-yyyy", 
                        selectYears: 2, 
                        firstDay: 1,
                        min: true,
                        onSet: function() {JQuery("#elem44").val(this.get("value"));}
			});
        });
</script>'
  1. Validation works fine
  2. disable dates also works fine

Problem:
  • Field it's not being populated with the chosen date
  • I have 2 calendar fields: how the code would be to disable past dates on both?

Thank you!

Please Log in or Create an account to join the conversation.

Responsive Calendar - Date Format and Disable Past Dates 4 years 11 months ago #203393

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 280
Hello there,

1) Locate this line:
onSet: function() {JQuery("#elem44").val(this.get("value"));}
and replace it with line:
onSet: function() {JQuery("#ff_elem44").val(this.get("value"));}
You are missing this part "ff_".

2) You can set 2 or more functions inside the echo statement like this:
echo '<script type="text/javascript">
                                        
    JQuery(document).ready(function () {
                          
        JQuery("#ff_elem3385_calendarButton").pickadate({
			format: "mm-dd-yyyy", 
                        selectYears: 2, 
                        firstDay: 1,
                        min: true,
                        onSet: function() {JQuery("#ff_elem3385").val(this.get("value"));}
			});
        });
    JQuery(document).ready(function () {
                             
        JQuery("#ff_elem3394_calendarButton").pickadate({
			format: "mm-dd-yyyy",  
                        selectYears: 2, 
                        firstDay: 1,
                        min: true,
			onSet: function() {JQuery("#ff_elem3394").val(this.get("value"));}
		});
        });
</script>'
Only write the correct ID of each calendar.
Let me know if this works now.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
The following user(s) said Thank You: rcaragao

Please Log in or Create an account to join the conversation.

Last edit: Post by marko.bosnjak.

Responsive Calendar - Date Format and Disable Past Dates 4 years 11 months ago #203418

  • Topic Author
  • rcaragao
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 0
It worked well, Thank you!

Please Log in or Create an account to join the conversation.

Responsive Calendar - Date Format and Disable Past Dates 4 years 11 months ago #203420

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 280
Great, I'm glad it works.
Let us know if you have more questions.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
The following user(s) said Thank You: rcaragao

Please Log in or Create an account to join the conversation.

Responsive Calendar - Date Format and Disable Past Dates 1 month 2 days ago #274604

  • gateirow
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 5
  • Thanks: 0
Hi,
in which part is this implemented?

Please Log in or Create an account to join the conversation.

Responsive Calendar - Date Format and Disable Past Dates 1 month 3 days ago #274605

  • tihana.krivic's Avatar
  • tihana.krivic
  • Away
  • Moderator
  • Moderator
  • Posts: 10536
  • Karma: 3
  • Thanks: 705
Hi,

this first code with function ff_00N1a000006liih_validation(element, message)
should be in calendar->Properties->Validation->Custom.
00N1a000006liih->this should be replaced with name of calendar (not title)


Second code is in form->Advanced->More options->Form pieces->Before form->check Custom

If you need more help, let me know

Regards,
Tihana

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

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!