I have a simple html form:
JavaScript
x
6
1
<form action="test" method="post" id="myForm">
2
<input type="text" name="myTextField">
3
<input type="text" name="myTextField2">
4
<input type="text" name="dontSubmitThisField">
5
</form>
6
And I need to submit it with JavaScript, but I want to exclude the dontSubmitThisField
field from the request. Is there a way of doing that without Ajax?
Advertisement
Answer
Just disable the field.
Either do it via HTML if the field cannot be updated by the user: http://www.w3schools.com/tags/att_input_disabled.asp
Or do it via jQuery with a on submit event:
JavaScript
1
4
1
$('#myForm').submit(function(){
2
$('input[name="dontSubmitThisField"]').prop('disabled', true);
3
});
4