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?")){
 document.res_reg.reset();
 }
 }

function cancelAction() {
 var cancel=confirm("Are you sure you want to cancel?")
 if (cancel==true)
 {
 // Go back (Same result as pressing browser back button)
 history.go(-1);
 }
 else
 {
 <!-- nothing happens-->
 }
 }
 </script>
 <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

required

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