View on GitHub

Jquery.dirty

A simple jquery plugin for checking if a form has been modified

Download this project as a .zip file Download this project as a tar.gz file

jquery.dirty

A jQuery plugin to determine when a form has been modified (dirtied) and act accordingly

All state information about the form is held in the data object for the form rather than adding data- attributes to the DOM

Usage

$("#myForm").dirty();

Options

Methods

$("#myForm").dirty("isDirty"); returns true if a form has been modified

$("#myForm").dirty("isClean"); returns true if a form has not been modified

$("#myForm").dirty("refreshEvents"); remove and reapply events. Can be used if content is dynamically added to form

$("#myForm").dirty("resetForm"); reset the form to the original state when $("#myForm").dirty(); was called

$("#myForm").dirty("setAsClean"); set the current state of the formas the 'clean' state. Calling resetForm after this will restore the form to the state when setAsCleanwas called

$("#myForm").dirty("showDirtyFields"); returns jQuery array of all modified fields in the form