As @Sergio said, you can disable the fields you do not want to send, follow the code in javascript:
$(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 fire the function that looks for inputs
within divs
hidden and disable them.
NOTE: If you need to put other fields that are not inputs
, such as textarea
, simply comma-separated the selector 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>