Validate a Reset Button

Tagged with Javascript validation validate

Language: JavaScript

If you’ve ever wanted to have a reset button confirm the reset so that people dont accidentally reset a long form and get frustrated this works well. Basically you create you’re own button for the reset. Where i have “frmInvitation” input the name of your form “frmname”.

View as text

<Input type="button" value="Reset" onclick="confirmReset()"/>  


<script type="text/javascript">
    function confirmReset() {
        if(confirm("Are you sure you want to reset form?") == true) {
	    document.getElementById("frmInvitation").reset();
	}
    }
</script>
Original snippet written by Josh Peot
Last updated at 10:34 AM on Oct 10, 2008

SnippetStash costs money to host and develop. The service is free for everyone to use
but if you found it useful please consider making a small donation.