The Big Spring Sale! Up to 50% off!

Prevent form submit override with JavaScript

saturnix
2 Posts
saturnix posted this 12 September 2020
Ask a Question

Is there any way I can prevent all the JavaScript nonsense added to override the standard <form> functionality?

I'd like to simply do a POST submit to my own link, but the exported HTML has some JavaScript in it that overrides this and instead tries to do some AJAX calls to the URL I provide.

How can I prevent this?

Many thanks!

Is there any way I can prevent all the JavaScript nonsense added to override the standard &lt;form&gt; functionality? I'd like to simply do a POST submit to my own link, but the exported HTML has some JavaScript in it that overrides this and instead tries to do some AJAX calls to the URL I provide. How can I prevent this? Many thanks!
Vote to pay developers attention to this features or issue.
2 Replies
Order By: Standard | Newest
JasonK
1 Posts
JasonK posted this 30 June 2021

Actually this is possible. Since NicePage uses jQuery, you can basically override the event listener for the submit button and change it to do whatever you like.
Here's an example. You can include this code in the additional HTML section in the page settings:

<script>
    window.onload = function() {
        $(".u-form-submit > a").off();
        $(".u-form-submit > a").on( "click", function() {
            alert("sending post...");
            $.post( "ajax/test.html", function( data ) {
              $( ".result" ).html( data );
            });
        });
    }
</script>

This example uses AJAX to POST but you could easily change it to perform a direct form post.

Actually this is possible. Since NicePage uses jQuery, you can basically override the event listener for the submit button and change it to do whatever you like. Here's an example. You can include this code in the additional HTML section in the page settings: <script> window.onload = function() { $(".u-form-submit > a").off(); $(".u-form-submit > a").on( "click", function() { alert("sending post..."); $.post( "ajax/test.html", function( data ) { $( ".result" ).html( data ); }); }); } </script> This example uses AJAX to POST but you could easily change it to perform a direct form post.
Support Team
Support Team posted this 14 September 2020

Hi,

You cannot edit the code that Nicepage creates. But if you want, you can use your custom submit file for the form. You can find more details here:
https://nicepage.com/doc/create-a-simple-html-contact-form-25066

...................................................
Sincerely,
Hella
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hi, You cannot edit the code that Nicepage creates. But if you want, you can use your custom submit file for the form. You can find more details here: https://nicepage.com/doc/create-a-simple-html-contact-form-25066 ................................................... Sincerely, Hella Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
You must log in or register to leave comments