TEMA:

Responsive Calendar - Date Format and Disable Past Dates 5 años 6 meses antes #203355

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

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

Responsive Calendar - Date Format and Disable Past Dates 5 años 6 meses antes #203393

  • marko.bosnjak
  • Fuera de línea
  • Usuario está bloqueado
  • Usuario está bloqueado
  • Registered
  • Mensajes: 2222
  • Gracias recibidas: 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!
El siguiente usuario dijo gracias: rcaragao

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

Última Edición: Post by marko.bosnjak.

Responsive Calendar - Date Format and Disable Past Dates 5 años 6 meses antes #203418

  • Autor del tema
  • rcaragao
  • Fuera de línea
  • Navegador Junior
  • Navegador Junior
  • Registered
  • Mensajes: 22
  • Gracias recibidas: 0
It worked well, Thank you!

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

Responsive Calendar - Date Format and Disable Past Dates 5 años 6 meses antes #203420

  • marko.bosnjak
  • Fuera de línea
  • Usuario está bloqueado
  • Usuario está bloqueado
  • Registered
  • Mensajes: 2222
  • Gracias recibidas: 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!
El siguiente usuario dijo gracias: rcaragao

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

Responsive Calendar - Date Format and Disable Past Dates 8 meses 1 semana antes #274604

  • gateirow
  • Fuera de línea
  • Navegador Iniciado
  • Navegador Iniciado
  • Registered
  • Mensajes: 18
  • Gracias recibidas: 0
Hi,
in which part is this implemented?

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

Responsive Calendar - Date Format and Disable Past Dates 8 meses 1 semana antes #274605

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

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.059 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!