I am developing a search form.
Search Form has 2 parts, First simple search with some select, input, and submit button. Second contains many select, check box, radi
Try using the following in your $(function(){ ... })
section:
$('form').submit(function(){$('input[value=]',this).remove();return true;})
this will remove any empty input
elements from your form before submitting it. You can of course modify it to include also non-selected selector boxes etc.
You can bind a function on the form submit event and remove/disable all input with an empty value. Like this :
your_form.submit(function() {
your_form.find('input').each(function() {
var input = $(this);
if (!input.val()) {
input.remove(); // or input.prop('disabled', true);
}
});
});
I think you have to validate all those fields before including into the .get()
method and do not include to the .get()
method those inputs that has no values.