Ninja Forms onsubmit button in form function

I am trying to add onsubmit="return blahblah();" inside the <form> element. However, it just echo’s outside of the form every single time.

function ninja_forms_add_on_submit( $form_id ) {
  echo 'onsubmit="something"';
}
add_action( 'ninja_forms_display_open_form_tag', 'ninja_forms_add_on_submit' );

Been going through the actions documentation: http://ninjaforms.com/documentation/developer-api/actions/

Read More

The reason why im doing this is because i want the onsubmit to fire an ajax call before it starts the action.

Thanks again

Related posts

Leave a Reply

1 comment

  1. As you might have realized the function you assigned to be executed on ninja_forms_display_open_form_tag will be executed as soon, as the Ninja Forms renders the opening form tag; but the opening tag also includes the closing > – so there is no way to actually set the onsubmit attribute, or any attributes for that matter.

    As mentioned by Culyx in the comments you could assign the onsubmit callback with jQuery.