Skip to content

Instantly share code, notes, and snippets.

@elioermini
Created August 25, 2015 16:32
Show Gist options
  • Select an option

  • Save elioermini/9c2dad5ca5b64feb1866 to your computer and use it in GitHub Desktop.

Select an option

Save elioermini/9c2dad5ca5b64feb1866 to your computer and use it in GitHub Desktop.
Script to Confirm form Submission when edited
/**
* Created by Elio on 16/07/15.
*/
jQuery(document).ready(function() {
var formmodified=0;
console.log(formmodified);
jQuery('form *').keyup(function(){
formmodified=1;
console.log(formmodified);
});
jQuery("#save_butn").click(function() {
formmodified = 0;
console.log(formmodified);
});
window.onbeforeunload = confirmExit;
function confirmExit() {
if (formmodified == 1) {
return "New information not saved. Do you wish to leave the page? ---- Neue Informationen nicht gespeichert. Wollen Sie die Seite verlassen möchten?";
}
}
jQuery('.required-entry').closest(".form-group").find("label").prepend("<span style='color:red;'>*</span>");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment