I have a form with some input passed to GET, and I don't want to have all fields in GET; I want to avoid empty fields.
So, a concrete example for:
<form method="GET" action="an_url">
<input type="text" name="field1"/>
<input type="text" name="field2"/>
<input type="text" name="field3"/>
<input type="submit" value="submit"/>
</form>
I suggested that fields disabled by the html attribute "disabled" should not be passed to GET.
So, I made js (based on jquery) to disable empty fields in submit, something like this:
$("form").submit(function() {
$(this).find("input[type=text]").each( function () {
if (!$.trim($(this).val())) {
$(this).attr("disabled", "true");
}
});
});
However, this does not work. Any ideas?
source
share