Filling out the form field and displaying all form fields except the hidden field in this form

Can someone provide me an example to view all fields of the form and show these fields, except for hidden fields in this form.

Pseudocode:

for(i=0;i<formFields.length;i++) { if(formFields[i]!= 'hidden field') then formFields[i].show(); } 
+5
source share
1 answer

You can try to loop through the fields with the following code; however, if the fields have a hidden attribute, they will be hidden. No need to apply .show to elements that will already be displayed.

Scroll through all the visible fields:

 $("#Form1 :input").not(':button, :hidden').each(function() { // do whatever with the fields here }); 

Update

 // show form, clear hidden values $(".dropdown").on('change', function() { if ($(this).val() == "Show all fields") { $("#Form1").show(); $("#Form1 :input").is(':hidden').each(function() { $(this).val(''); }); } }); 

Update 2:

 $(".dropdown").on('change', function() { if ($(this).val() == "Show all fields") { $("#Form1").show(); $('#Form1 *').filter(':input').each(function() {(...)}); } }); 
+1
source

All Articles