How do I perform an action immediately after an has already reset the form elements?
You always can use jQuery, or do some tricks with form reset event itself.
Forms have a reset
event that you can listen for.
<script>
function resetHandler() {
// code
}
</script>
<form ... onreset="resetHandler();">
</form>
Of course, it's bad practice to add javascript handlers this way, so you'd want to use .addEventListener/.attachEvent
or jQuery.bind()
, but you get the idea.
Write code/events which you wanted to call in middle of this function. I have tested this. Working good.
$(document).ready(function() {
$("input:reset").click(function() { // apply to reset button's click event
this.form.reset(); // reset the form
// call your functions to be executed after the reset
return false; // prevent reset button from resetting again
});
});
Try :
<input type="reset" onclick="return resetForm();"/>
function resetForm(){
setTimeout(function(){
// do whatever
}, 50);
return true;
}