In the past when I've wanted to disable the default action of a form, I've done
<form action="javascript:void(0);">
We now employ a CSP (Content Security Policy) to disallow inline JavaScript. How can we disable the default form action without the inline js?
use jquery
<script>
$(document).ready(function () {
$("#form").submit(function (e) {
//stop submitting the form
e.preventDefault();
return true;
});
});
</script>
You can disallow all form actions from the HTML document by setting form-action 'none'.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/form-action
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With