• Resolved Windurin

    (@windurin)


    Hi. This is a rather unique case but I’m developing a sort of bookmark feature for my site. Chapter Bookmark is a CPT for which I have a create post ACFE form.

    I’ve found code that allows me to insert highlighted text into my ACF textarea field on the form on button click using a JS function. This is the code I’m using:

    https://snippi.com/s/kf2uvvr

    And you can see it in action in a short video here:

    But ideally I’d like to do this action without a button click and perhaps call the function after finishing highlighting the text. Is there some solution to getting this functionality?

    For example, calling the function and inserting the text on form submission or perhaps before submission since it may not be inserted early enough? Failing this, even having a button within the form itself that calls the function and inserts the currently selected text.

    I know how to call PHP functions on form submission but I’m not sure if/how it can be done with JS.

    Appreciate any help you can provide. Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    You can perform an action after the form validation (and before its submission) using the native ACF JS hook validation_complete. See documentation.

    If you need to perform an action after the form submission (when the page has been reloaded), then you can use the acfe/form/submit/success JS hook (which is specific to ACFE Forms). See documentation.

    You can also add a button within the form using the ACFE Button Field and add your own JS logic using the ACF JS API.

    Hope it helps!

    Have a nice day!

    Regards.

Viewing 1 replies (of 1 total)

The topic ‘Calling A JavaScript Function On Or Before Form Submission?’ is closed to new replies.