Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do hidden form elements get submitted?

Tags:

If jQuery's toggle() is used on a <div> containing form elements, will those form elements get submitted with the form, even though they are hidden?

My code (though probably not needed for this particular question):

$('.cms_loop_title').click(function(){     $ctg = $(this).attr('rel');     $('.'+$ctg).toggle();     //alert($ctg); }); 
like image 211
Dizzy Bryan High Avatar asked Oct 17 '11 14:10

Dizzy Bryan High


People also ask

Is hidden input submitted?

Even though the hidden input cannot be seen at all, its data is still submitted.

How do I submit a hidden input to a form?

Definition and Usage. The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

Is input type hidden safe?

Since they are not rendered visible, hidden inputs are sometimes erroneously perceived as safe. But similar to session cookies, hidden form inputs store the software's state information client-side, instead of server-side. This makes it vulnerable.

How do you hide the form of an element?

To hide an element, set the style display property to “none”. document. getElementById("element").


2 Answers

Yes, they'll get submitted unless they are removed from the document or have the disabled attribute set on them.

For more information, see the HTML5 Working Draft — Section 4.10.22.4 Constructing the form data set. The information there is more-or-less the same as previous HTML versions.

like image 194
Andy E Avatar answered Sep 22 '22 22:09

Andy E


In order to prevent submitting, you have to disable the elements. Hiding doesn't do the trick (I had the same issue a while ago)

like image 27
Alex Avatar answered Sep 24 '22 22:09

Alex