TOPIC:

Date element - future date only 4 weeks 5 hours ago #276127

  • Topic Author
  • greendome
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 40
  • Thanks: 0
Hi,

I'm working a booking form and would like users to only select a date that is 2 or more day in advance from the date of booking.

For example:

If today is Friday, 22 August. The next booking must be from Monday onward, so users can't select the current day (Friday), Saturday or Sunday.

Is this doable?

Thank you.

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

Last edit: Post by greendome.

Date element - future date only 3 weeks 4 days ago #276142

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10780
  • Karma: 3
  • Thanks: 720
Hi,

which date format do you use?

Also, one more question:
I assume that you have start and end date of booking, and when user open start date, and select today's date or other 2 date (3 days), then error message should be here ? Something like this?

Regards,
Tihana

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

Date element - future date only 3 weeks 4 days ago #276145

  • Topic Author
  • greendome
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 40
  • Thanks: 0
Date format is DD/MM/YYYY.

There is no end date, only a meeting date. This date the user will already know but on the booking form, they can't select their meeting date if less than 3 days because not enough time to do the relevant paperwork.

For example:

Today is 25/07/2022. If the user's meeting date is today or 26th or 27th, they cant select a date as not enough time for paperwork. There should be an error message and can't submit the form as date is required field. However, 28th onwards is fine.

Thank you.

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

Date element - future date only 3 weeks 4 days ago #276151

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10780
  • Karma: 3
  • Thanks: 720
Hi,

got it.

Please go to your calendar element->Validation->check Custom and put:
function ff_nameofcalendar_validation(element, message)
{
var pattern = /[0-3][0-9]\/(0|1)[0-9]\/(19|20)[0-9]{2}/;
   if(pattern.test(element.value))
   {
      var date_array = element.value.split('/');
      var day = date_array[0];
 
      // Attention! Javascript consider months in the range 0 - 11
      var month = date_array[1] - 1;
      var year = date_array[2];
 
      // This instruction will create a date object
      birthDate = new Date(year,month,day);
 
      if(year != birthDate.getFullYear())
      {
         return message == '' ? "Date isn't entered in the right format.\n" : message;
      }
 
      if(month != birthDate.getMonth())
      {
         return message == '' ? "Date isn't entered in the right format.\n" : message;
      }
 
      if(day != birthDate.getDate())
      {
         return message == '' ? "Date isn't entered in the right format.\n" : message;
      }
   }
   else
   {
      return message == '' ? "Date isn't entered in the right format.\n" : message;
   }

var vDate = new Date(Number( element.value.split("/")[2]),Number(element.value.split("/")[1]-1),Number(element.value.split("/")[0]),0,0,0).getTime();

 var today = new Date();
 today.setDate(today.getDate()+2);
  

if(vDate < today)
     {
          if (message=='') message = element.name+" faild in my test.n";
          return message;
     }
return'';
} // ff_nameofcalendar_validation
Please replace nameofcalendar with name of your calendar element (not title)

If you need more help let me know

Regards,
Tihana
The following user(s) said Thank You: greendome

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

Date element - future date only 3 weeks 4 days ago #276155

  • Topic Author
  • greendome
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 40
  • Thanks: 0
You're a star!

Thank you so much - this worked as expected.

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

Date element - future date only 3 weeks 4 days ago #276156

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10780
  • Karma: 3
  • Thanks: 720
Hi,

super :)

I am glad I was able to help

If you need anything else, feel free to ask

Regards,
Tihana

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

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.048 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!