Clear form with JavaScript


/ Published in: JavaScript
Save to your folder(s)

JavaScript is the only option, if you want to have the ability to clear all form fields. Yes, HTML form has Reset method, but if the form has initial values, then Reset will return the form to the initial state instead of clear input fields. This example also shows how to create an access loop for each form element. You can uncomment alert before "switch" line and you will see the message before element value is cleared. Drop down select-one will be set to its first option because it can not be treated like input text field or select-multiple

URL: http://www.redips.net/javascript/clear-form/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.