How to not serialize a particular type of element with jQuery

Asked

Viewed 42 times

4

I have a form and I don’t want to "serialize" the input’s of the kind checkbox, soon tried some options such as below:

var form = $('#service-item-form :not(:input[type="checkbox"])').serialize();

But unfortunately it doesn’t work! I wonder what I can try to do to resolve this issue.

  • 1

    Related English: http://stackoverflow.com/questions/4556172/excluding-certain-inputs-on-serialize

  • @Wallacemaxters, unfortunately it didn’t work.

  • 1

    Put the code of your form, because there is some error in your question. The answers have been tested and work correctly.

2 answers

4

Try the following on:

var form = $('#service-item-form')
    .find('input, textarea, select')
    .not(':checkbox')
    .serialize()
  • unfortunately it didn’t work.

  • 1

    @Joãomanolo sure the id in HTML is "service-item-form"

  • Yes! Thanks for your help, but @Wallace Maxters' reply worked.

2


According to the reply of SOEN:

$('#ofform').on('submit', function(e) {
    e.preventDefault();
    var serializedReturn = $('input[name!=security]', this).serialize();        
});

I would prefer it that way, using the not:

$("form").find(":input").not(':checkbox').serialize()
  • The last option Wallace came true!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.