How to serialize everything but the checkbox elements in jQuery.serialize()?
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts I will will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.
My quesiton was if there is a way to serialize all form elements using serialize() function except the checkboxes?
The answer, by Simeon, was:
The .serialize() method can act on a jQuery object that has selected individual form elements, such as
<input>
,<textarea>
, and<select>
.You could do this:
var s = $('#post-form').find('input, textarea, select').not(':checkbox').serialize()
Leave a Comment