jQuery Plugin For Checking Form Has Been Changed - dontJustLeaveMe

File Size: 5.05
Views Total: 1687
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin For Checking Form Has Been Changed - dontJustLeaveMe

dontJustLeaveMe is an useful jQuery plugin for checking the form values of the page have been changed, if yes, it will popup a alert window to make sure they want to leave when closing the current page. It is very useful to prevent from losing data when accidently closing window, navigating away, etc.

See also:

How to use it:

1. Create a standard html form

<form>
<label>name
<input name=foo>
</label>
<label>email
<input name=bar type=email value="[email protected]">
</label>
<fieldset>
<legend>favorite color</legend>
<label>red
<input name=baz type=radio value=1>
</label>
<label>green
<input name=baz type=radio value=2 checked>
</label>
<label>blue
<input name=baz type=radio value=3>
</label>
</fieldset>
<label> yes or no?
<select name=bomb>
<option></option>
<option>yes</option>
<option>no</option>
</select>
</label>
<input type=submit>
</form>

2. Include jQuery library and jQuery dontJustLeaveMe plugin on the web page

<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script> 
<script src="jquery.dontJustLeaveMe.js"></script> 

3. Call the plugin

<script>
  $('form').dontJustLeaveMe();
</script>

This awesome jQuery plugin is developed by fusionbox. For more Advanced Usages, please check the demo page or visit the official website.