regex - jquery remove empty or white space values from url parameters -
i using form.serialize()
list of parameters.
if parameter empty or space, want remove list.
for example:
testaction.action?a=1&b=&c=3
should give me
testaction.action?a=1&c=3
first using regex:
params = params.replace(/[^&]+=\.?(?:&|$)/g, '');
but problem if url
testaction.action?a=1&b=2&c=
regex return me
testaction.action?a=1&b=2& (i have & @ end!)
after tried jquery solution
$('.myform').find('input, select').not("[value='']").serialize();
but working empty values -> if have space parameter in value pass.
can me other solution?
thanks
try
$(".myform :input").filter(function () {return $.trim(this.value);}).serialize();
Comments
Post a Comment