Read INPUT Types
If what you're saying is that you want to get all inputs inside a form that have a value without worrying about the input type, try this: Example: http://jsfiddle.net/nfLfa/ var $inputs = $('form').find(':checked,:selected,:text,textarea').filter(function() { return $.trim( this.value ) != ''; }); Now you should have a set of input elements that have some value. You can put the values in an array: var array = $inputs.map(function(){ return this.value; }).get(); Or you could serialize them: var serialized = $inputs.serialize();
by bizamajig
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<form>
<textarea name='area1'></textarea>
<textarea name='area2'>some textarea</textarea>
<input type='text' name='text1' />
<input type='text' name='text2' value='some text' />
<input type='radio' name='radio' value='radio1' />
<input type='radio' name='radio' value='radio2' checked='checked' />
<input type='checkbox' name='checkbox1' value='checkbox1' />
<input type='checkbox' name='checkbox2' value='checkbox2' checked='checked' />
<select>
<option value='option1'>option one</option>
<option value='option2' selected='selected'>option two</option>
</select>
</form>
JavaScript
var $inputs = $('form').find(':checked,:selected,:text,textarea').filter(function() {
return $.trim( this.value ) != '';
});
alert($inputs.length);
var array = $inputs.map(function(){
return this.value;
}).get();
alert(array);
var serialized = $inputs.serialize();
alert(serialized);