简体   繁体   中英

Preventing form elements from submitting

I have a use case that is odd in nature and I know there should be a better way to do this, but those issues aside is there a way to stop certain form elements from submitting?

My only thought would be to remove the 'unwanted' elements from the page in reaction to the Submit action, but I don't want them to actually be visibly removed to the end users.

You could insert input fields with no "name" attribute:

<input type="text" id="empty-example" />

Or you could simply remove them once the form is submitted (in jquery):

$("form").submit(function() {

   $(this).children('#empty-example').remove();

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM