Reputation: 3451
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?
Upvotes: 3
Views: 861
Reputation: 1086
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
Upvotes: 1
Reputation: 126
use jquery
<script>
$(document).ready(function () {
$("#form").submit(function (e) {
//stop submitting the form
e.preventDefault();
return true;
});
});
</script>
Upvotes: 1