validate message.
{$ui = [
- 'action' => string Required URL
- 'method' => string Required Method "post" or "get"
- 'id' => string Form id
- 'file' => boolean If including file upload set to true
- 'validate' => boolean If true, include Abide Form Validation
- 'validateFocusMsg' => boolean If true focuses on validateMessage on error - May be a problem if there's more than one validated form (may have to ID these messages separately)
- 'validateID' => string Unique text that will be added to the validate message container to ensure that it is unique
- 'validateMessage' => string Message to show for a validation error, Defaults to "There are some errors in your form."
+ 'action' => string Required URL
+ 'method' => string Required Method "post" or "get"
+ 'id' => string Form id
+ 'file' => boolean If including file upload set to true
+ 'validate' => boolean If true, include Abide Form Validation
+ 'validateFocusMsg' => boolean If true focuses on validateMessage on error - May be a problem if there's more than one validated form (may have to ID these messages separately)
+ 'validateID' => string Unique text that will be added to the validate message container to ensure that it is unique
+ 'validateMessage' => string Message to show for a validation error, Defaults to "There are some errors in your form."
+ 'leaveModifiedFormCheck' => boolean If set and user tries to leave the page after modifying form input it will warn them and ask if they want to abandon their changes.
]}
*}
<form
jQuery(document).ready(function($){
- // When submit button is clicked, disable the beforeunload message
- $('.glm-form-submit-button').on('click', function() {
- glmFormDataChangesPending = false;
- return true;
- });
-
- // If submit is required and we're laving the page, alert the user
- $(window).on('beforeunload', function(){
-
- // Check if any of the wp_editor instances is dirty (tinyMCE)
- // ** THIS MAY NOT BE A GOOD LONG TERM SOLUTION **
- if (typeof tinyMCE != "undefined" && typeof tinyMCE.editors != "undefined") {
- for(i=0; i<tinyMCE.editors.length; i++){
- if (!tinymce.editors[i].isNotDirty) {
- glmFormDataChangesPending = true;
- }
- }
- }
-
- if (glmFormDataChangesPending) {
+ {if !empty($ui.leaveModifiedFormCheck)}
+
+ // When submit button is clicked, disable the beforeunload message
+ $('.glm-form-submit-button').on('click', function() {
+ glmFormDataChangesPending = false;
return true;
- }
+ });
+
+ // If submit is required and we're laving the page, alert the user
+ $(window).on('beforeunload', function(){
+
+ // Check if any of the wp_editor instances is dirty (tinyMCE)
+ // ** THIS MAY NOT BE A GOOD LONG TERM SOLUTION **
+ if (typeof tinyMCE != "undefined" && typeof tinyMCE.editors != "undefined") {
+ for(i=0; i<tinyMCE.editors.length; i++){
+ if (!tinymce.editors[i].isNotDirty) {
+ glmFormDataChangesPending = true;
+ }
+ }
+ }
- return;
- });
+ if (glmFormDataChangesPending) {
+ return true;
+ }
+
+ return;
+ });
+
+ {/if}
// Setup field validation
{if !empty($ui.validateFocusMsg)}