Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
Javascript working only when logged in as admin

I added following script to change the date formate of elementor form

<script>
jQuery(document).ready(function () {
    setTimeout( function(){
        jQuery('.flatpickr-input').each(function(){ flatpickr( jQuery(this)[0] ).set('dateFormat', 'm/d/Y');});
        jQuery('.elementor-date-field').removeAttr('pattern');
    }, 1000 );
});
</script>

and the following function to restrict the past dates

// Validate the date field min value from today.
add_action( 'elementor_pro/forms/validation/date', function( $field, $record, $ajax_handler ) {

    // make sure ts the correct date field
    if ( 'YOUR_FIELD_ID' === $field['id'] ) {
        return;
    }

    $min_allowed_date = strtotime( 'today' );
    


    $form_date = strtotime( $field['value'] );
    if ( $min_allowed_date > $form_date ) {
        $ajax_handler->add_error( $field['id'], 'The Minimum allowed date is, ' . date( 'm/d/Y', $min_allowed_date ) );
    }
    
}, 10, 3 );

it is working only when I logged in as admin. But the javascript is not working when I test from an incognito window like a normal site visiter.

please help me to fix this issue

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I changed the javascript to

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
      jQuery( document ).ready( function( jQuery ){
            setTimeout( function(){
                  jQuery('.flatpickr-input').each(function(){ flatpickr( $(this)[0] ).set('dateFormat', 'm/d/Y');});
            }, 1000 );
      });
 </script>

Now it is working correctly Thank you

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda