Search code examples
jqueryformsserializationfieldset

serialize fieldset content of a form


this is my code: http://jsfiddle.net/michelejs/Pt6LQ/25/

I would to serialize only the fieldset name= cap1.

So I tried to modify

$('#result').text(JSON.stringify($('form').serializeObject()));

in

        $('#result').text(JSON.stringify($('fieldset#cap1').serializeObject()));

but it doesn't work and return me {}. How can I modify the code for serialize only one fieldset content and not all the form?

Thanks a lot.


Solution

  • You should use:

     $('fieldset#cap1 input').serializeObject()));
    

    updated fiddle:

    http://jsfiddle.net/Pt6LQ/26/