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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -