As @Sergio said, you can disable the fields you don’t want to send, follow the javascript code:
$(document).ready(function() {
$('form').submit(function() {
$(this).find('div:hidden input').prop('disabled', true);
});
});
I monitor the submission of the form, when this event is triggered I trigger the function you seek inputs
inside divs
hidden and disabled them.
OBS.: If there is a need to put other fields that are not inputs
, as an example textarea
, just separate by comma on the dial, like this:
.find('div:hidden input,textarea')
The structure of HTML would look like this:
<form>
<div style="display: none">
<input type="text" name="campo1">
</div>
<div>
<input type="text" name="campo2">
</div>
</form>
Just to comment that no solution presented on the client side (javascript or css for example) should be used as a security system that that data will not be sent, as it can easily be reactivated by the console or plugins, then additional checks should be performed on the server side.
– Jader A. Wagner