Wednesday, 13 March 2013

Dirty Forms

Prevent users from losing data when editing forms:


Dirty Forms is a flexible jQuery plugin to help prevent users from losing data when editing forms.Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into.
Prerequisites

Must have jQuery Library version 1.4.2 or higher.
easy to use.

<script type="text/javascript" src="http://mal.co.nz/wp-content/themes/boldy/js/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="jquery.dirtyforms.js"></script>
<script type="text/javascript">

$(document).ready(function(){

      $('#testform').dirtyForms();
 
 $('#dirtycheck').click(function(){
 if($.DirtyForms.isDirty()){
 alert("Your form is so dirty...");
 }else{
 alert("Your form is a saint, nothing dirty about her");
 }
    });

});
</script>

<form id="testform">
<input type="text" value="Change me to make me dirty" />
<input id="dirtycheck" type="button" value="Am I dirty?" />
</form>

Public Methods

$.DirtyForms.isDirty() will return true if any watched elements are considered dirty. 
Syntax: if($.DirtyForms.isDirty())


0 comments:

Post a Comment

Topics

ADO .Net (2) Ajax (1) Angular Js (17) Angular2 (24) ASP .Net (14) Azure (1) Breeze.js (1) C# (49) CloudComputing (1) CMS (1) CSS (2) Design_Pattern (3) DI (3) Dotnet (21) Entity Framework (3) ExpressJS (4) Html (3) IIS (1) Javascript (6) Jquery (9) Lamda (3) Linq (11) Mongodb (1) MVC (48) NodeJS (7) RDLC (1) Report (1) Sql Server (29) SSIS (3) SSRS (2) UI (1) WCF (12) Web Api (10) Web Service (1) XMl (1)