CancelImage Upload

How to reset a form and its fields via a Link with JavaScript

Reset buttons are not the only method available by which form fields can be reset. Indeed the simple JavaScript command reset() can be called upon from numerous elements including anchor tags and onClick images. Here is the code that needs to be placed within these element's onClick or href attributes:


As you can see from the above code example you will need to address the form which you wish to reset specifically. Here this was accomplished via getElementById(). For a more extended look at how this function can be called upon, see the example below:

<title>How to reset a form and its fields via a link with JavaScript</title>

<form id="form1">
Title: <input type="text"><br>
Text: <textarea></textarea><br>
<input type="reset" value="Reset">

<a href="javascript:document.getElementById('form1').reset()">Reset Form1</a>


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •