JavaScript serialize form excluding specific class form serialize exclude,jquery serialize form exclude fields,javascript serialize

I want to serialize a form in such a way that it will exclude elements from some particular parent. e.g.

<form>
    <input type="text" name="myText" />
    <input type="hidden" name="myHidden" />
    <div class="ng-hide">
        <input type="text" name="insideText" />
    </div>
</form>

js code:

$('form').serialize(); // it will serialize all elements

I want to serialize form's all element excluding parent div.ng-hide. Off course before submit I can remove it like $('.ng-hide').remove() but needs some better solution.

Note: The example is minified version, there could be 3-4 ng-hide div and inside each there could be 10+ elements –

Answer:1

You can do as below:

var serializedReturn = $('input[name!=insideText]', this).serialize();  

Or to be in better way

$('form').find('input[name!=insideText]').serialize(); 

or to avoid whole div

$('form').not('.ng-hide').serialize(); 
Answer:2

I'm not fully getting this: var one = {}; var two = {}; var three = {}; three[one] = "one"; three[two] = "two"; console.log(three[one]); // Alerts "two" As I understand it, JS needs a string ...

I'm not fully getting this: var one = {}; var two = {}; var three = {}; three[one] = "one"; three[two] = "two"; console.log(three[one]); // Alerts "two" As I understand it, JS needs a string ...

if (Trim(document.getElementById("txtAffiliateName").value)=""){ alert("Please enter 'Affiliate Name'."); document.getElementById("txtAffiliateName").focus(); return false; } ...

if (Trim(document.getElementById("txtAffiliateName").value)=""){ alert("Please enter 'Affiliate Name'."); document.getElementById("txtAffiliateName").focus(); return false; } ...

  1. microsoft jscript runtime error
  2. microsoft jscript runtime error object expected
  3. microsoft jscript runtime error '800a138f'
  4. microsoft jscript runtime error 'console' is undefined
  5. microsoft jscript runtime error permission denied
  6. microsoft jscript runtime error 800a1391
  7. microsoft jscript runtime error 'jquery' is undefined
  8. microsoft jscript runtime error in eclipse
  9. microsoft jscript runtime error subscript out of range
  10. microsoft jscript runtime error 'module' is undefined
  11. microsoft jscript runtime error ansys
  12. microsoft jscript runtime error object required
  13. microsoft jscript runtime error 'sys' is undefined
  14. microsoft jscript runtime error node js

I'm a d3 noob, so I need some help on creating a circular gauge chart. The chart should switch from red to yellow to green based on certain value. The problem is that I want to display the text ...

I'm a d3 noob, so I need some help on creating a circular gauge chart. The chart should switch from red to yellow to green based on certain value. The problem is that I want to display the text ...

I have a list of li elements which are a sidebar. I'm looking the way to add a class active to the one clicked, and remove that class from the others. This is my html code: ... <li ng-click="...

I have a list of li elements which are a sidebar. I'm looking the way to add a class active to the one clicked, and remove that class from the others. This is my html code: ... <li ng-click="...

  1. class element remove
  2. javascript element class remove
  3. js element class remove
  4. jquery element class remove
  5. element remove class name
  6. angular remove class from element