• Resolved furlosk

    (@furlosk)


    Hello,
    I have a Forminator form which has all the fields pre-filled from URL query and should submit itself automatically after page load. How should I accomplish this?

    I tried calling this:
    document.getElementById('forminator-module-468').submit()
    which works, but it ignores form validation and submits the form even if some required field is not filled. Moreover, it seems that this method does not use Ajax, but instead reloads the entire page.

    How to emulate “normal” form submit, i.e. a normal user click on submit button, which firstly checks if all fields are properly filled in, and only if everything validates, submits the form via Ajax and displays result above the form? Note that I have set the form submission method to Ajax.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter furlosk

    (@furlosk)

    Hah,
    as it usually happens, I found the solution just after I submitted the question!

    Turned out that the problem can be solved by using this custom HTML code below the form itself:

    <script type=”text/javascript”>
    //jQuery(document).ready(function() {
    jQuery(window).on(‘load’, function() {
    jQuery(‘#submit button’).click();
    });
    </script>

    Note that using jQuery(document).ready() function causes the code to be executed after the DOM is loaded, but before the form is fully initialised. If you want to have form validate the fields and prevent submission if something does not validate, you must use jQuery(window).on('load') function.

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    HI @furlosk

    I’m happy to hear that you have found solution!

    I’m sure a lot of people will find that useful in future so thanks fo rsharing it ??

    Best regards,
    Adam

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trigger Ajax form submit by Javascript’ is closed to new replies.