Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda