Home Forums Front-end Issues Frontend Inline JS causes error


Frontend Inline JS causes error

  • Apparently the plugin adds some inline JS to the <head> in frontend, namely

    <script type="text/javascript">
        jQuery('form.acf-form').append('<input type="hidden" name="acf[post_ID]" value="541"/>');
        jQuery('form.acf-form').append('<input type="hidden" name="acf[frontend]" value="true"/>');

    However this can cause errors in situations when jQuery is not present in <head>, f.e. if you deregister and reregister the shipped jquery version with the in_footer option for performance reasons.

    Could you add wrap your code in an if( window.jQuery ) { ... } or even better: Only add it to pages with frontend forms (I guess the code is there for this feature?).

    Or are there already hooks present to modify / disable the inline JS?


  • Hi @hatsumatsu

    I’m afraid ACF doesn’t add that script. Maybe there is a plugin or theme in your installation that add it? Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Fifteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.


  • You’re absolutely right, the JS in question was added by the Validated Field addon. Sorry for not checking before posting.

    I started a thread on the in case someone has these problems, too.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.