Stop an input field in a form from being submitted
You could insert input fields without "name" attribute:
<input type="text" id="in-between" />
Or you could simply remove them once the form is submitted (in jQuery
):
$("form").submit(function() {
$(this).children('#in-between').remove();
});
The easiest thing to do would be to insert the elements with the disabled
attribute.
<input type="hidden" name="not_gonna_submit" disabled="disabled" value="invisible" />
This way you can still access them as children of the form.
Disabled fields have the downside that the user can't interact with them at all- so if you have a disabled
text field, the user can't select the text. If you have a disabled
checkbox, the user can't change its state.
You could also write some javascript to fire on form submission to remove the fields you don't want to submit.