sikender sikender - 4 years ago 73
HTML Question

What is the difference between the clearing and reseting a web form?

I want to reset the value of a web page using JavaScript reset function. Which operation is the JavaScript performing first: the reset or a clear? And what is the difference in between the two?

Also, how can I retrieve a value using reset function?

Answer Source

Clear vs. Reset

Clearing a form makes all input fields blank, unchecks checkboxes, deselects multi-select choices, and so forth; whereas, resetting a form reverts all changes.

For example:

<input type="text" name="name" value="Timothy" />
<input type="reset" value="Reset" />

This produces an input field with a value of Timothy. Let's say the user then changes the value to Berners-Lee. If the user clicks the Reset button, the value of Berners-Lee will revert (reset) to Timothy.

Clearing the fields would involve changing the value attribute of the input field to the empty string, as follows:

<input type="text" name="name" value="" />

You can change the value attribute using JavaScript.

Retrieve Value

If you want to get (or set) the value for a field, using JavaScript, try reading these:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download