Created
August 25, 2015 16:32
-
-
Save elioermini/9c2dad5ca5b64feb1866 to your computer and use it in GitHub Desktop.
Script to Confirm form Submission when edited
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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