TEMA:

Date element - future date only 6 meses 2 semanas antes #276127

  • Autor del tema
  • greendome
  • Fuera de línea
  • Navegador Junior
  • Navegador Junior
  • Registered
  • Mensajes: 40
  • Gracias recibidas: 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.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by greendome.

Date element - future date only 6 meses 2 semanas antes #276142

  • Avatar de tihana.krivic
  • tihana.krivic
  • Fuera de línea
  • Moderador
  • Moderador
  • Registered
  • Mensajes: 12079
  • Gracias recibidas: 779
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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Date element - future date only 6 meses 2 semanas antes #276145

  • Autor del tema
  • greendome
  • Fuera de línea
  • Navegador Junior
  • Navegador Junior
  • Registered
  • Mensajes: 40
  • Gracias recibidas: 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.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Date element - future date only 6 meses 2 semanas antes #276151

  • Avatar de tihana.krivic
  • tihana.krivic
  • Fuera de línea
  • Moderador
  • Moderador
  • Registered
  • Mensajes: 12079
  • Gracias recibidas: 779
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
El siguiente usuario dijo gracias: greendome

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Date element - future date only 6 meses 2 semanas antes #276155

  • Autor del tema
  • greendome
  • Fuera de línea
  • Navegador Junior
  • Navegador Junior
  • Registered
  • Mensajes: 40
  • Gracias recibidas: 0
You're a star!

Thank you so much - this worked as expected.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Date element - future date only 6 meses 2 semanas antes #276156

  • Avatar de tihana.krivic
  • tihana.krivic
  • Fuera de línea
  • Moderador
  • Moderador
  • Registered
  • Mensajes: 12079
  • Gracias recibidas: 779
Hi,

super :)

I am glad I was able to help

If you need anything else, feel free to ask

Regards,
Tihana

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
Moderadores: ForumSupport
Tiempo de carga de la página: 0.062 segundos

Live Support Chat Opened!

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