Prevent users from losing data when editing forms:
Must have jQuery Library version 1.4.2 or higher.
<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>
Syntax: if($.DirtyForms.isDirty())
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