Does Bootstrap offer anything for clearing form input fields via a button?
Or do I need to roll my own through jquery?
From this post jQuery Validate resetForm() doesn't reset the onFocus validation, there seems to be a resetForm() method coming from jquery but I always get a object doesn't support method when I try to access that method.
To clear all the input in an HTML form, use the <input> tag with the type attribute as reset.
Scroll down to the Privacy and Security Section. Click Clear browsing data at top of Privacy and security section. At the Time range drop-down box, select All time. Make sure the option Cached images and files is checked and remove all other checkmarks.
You can use reset method (this is DOM element method, it is not jQuery object method), like this
$('form').get(0).reset() // or $('form')[0].reset()
Similar to other answers, if you want to reset the form (not necessarily clear it) you can use the following:
<button type="reset">
It's a little cleaner than embedding jQuery or javascript calls in the onclick...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With