Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!