Call JS function after Reset

Sometimes you may want to call a function after the reset is performed, with the resetted values. The form reset doesn't do this natively, but it can be done with event ordering in click events.

by vol7ron

HTML

<form>
    <div>
        <input type="text" />
    </div>
    Type something then hit <input type="reset" />
</form>

CSS

body {
    font-family: Verdana, Arial, sans-serif;
    font-size: 12px;
}

JavaScript

$(document).ready(function() {
    $("input:reset").on("click", function() {
        this.form.reset();
        window.alert($("input:text").val());        
        return false;              // to prevent resetting again
    });
});