When you are working with html form, you might need this below javascript code to implement form reset and cancel features.

 <script type="text/javascript">
 function clearform(){
 if(confirm("Are you sure you want to reset the form?")){

function cancelAction() {
 var cancel=confirm("Are you sure you want to cancel?")
 if (cancel==true)
 // Go back (Same result as pressing browser back button)
 <!-- nothing happens-->
 <input type="button" value="Reset" onclick="clearform();return false" />
 <input type="button" value="Cancel" onclick="cancelAction();" />

One thought on “Javascript Form Reset And Cancel

Leave a reply


<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>