Support » Plugin: Ninja Forms Contact Form - The Drag and Drop Form Builder for WordPress » Find focused input fields with jQuery

  • Resolved felixdorner



    I am running on Ninja Forms 3.0.27. I try to find input fields with jQuery based on whether they are focused or not. I approach this with the following script:

    $( 'input' ).on( 'focusin', function() {
      $(this).closest( '.field-wrap' ).addClass( 'focus' );    
    $( 'input' ).on( 'focusout', function() {
      if ( $(this).val()=='')
        $(this).closest( '.field-wrap' ).removeClass( 'focus' );      

    This used to work prior to Version 3. It is still working with own input fields I setup for testing outside a Ninja Form. Based on this I assume there is nothing wrong with the script itself. However I don’t get the script running inside a version 3 Ninja Form. The script simply don’t find the inputs inside a ninja form. Any ideas?

    • This topic was modified 3 years, 3 months ago by felixdorner.
Viewing 1 replies (of 1 total)
  • Plugin Contributor klhall1987


    Hey Felix,

    Two things. One, they need to make sure that their code is in a jQuery(document).on(‘nfFormReady’) callback. This works like:

    $( document ).on( 'nfFormReady', function( e, layoutView )  {
        // Custom code can go here, knowing that the form has loaded.
    } );

    Two, make sure that the .field-wrap class they are targeting is present and where they expect.

    If this snippet doesn’t help get your issue resolved. You might want to join our developer slack community. Someone there might be able to help get you pointed in the right direction. I’ve linked to the page to join the community below.

    Ninja Forms Developer Slack Community:


Viewing 1 replies (of 1 total)
  • The topic ‘Find focused input fields with jQuery’ is closed to new replies.