PreSaveAction in SharePoint

Hi All,

I am calling PreSaveAction() method in order to do some validation and show a custom Jquery Dialog box.

If i click on 'Agree' in Jquery dialog box, then it should continue to submit data on form to list.

My code is as follows

function agreeDisagree()
         {
         $j("#dialog").dialog({
                     title: "Terms & Conditions",
                     width: 450,
                     height: 280,
                     modal: true,
                     buttons: {
                         Agree: function () {
                         $j(this).dialog("close");
             
                         },
                    
            Disagree: function () {
                window.location='https://abc.com';
            }
                     }
                 });
                 
         }

var $j = jQuery.noConflict();
	function PreSaveAction(boolVal) {
	
            agreeDisagree();
            
        }

<input id="btnEnroll" type="button" value="Enroll" name="btnSave" onclick="javascript:return PreSaveAction(); {ddwrt:GenFireServerEvent('__commit')}" />

So, i am trying to do is if click on Enroll-> Call PreSaveAction()->Do validation->After validation show 'Agree/Disagree' popup.-> If Agree then submit.

July 29th, 2015 11:18am

on PreSaveAction function, you must return true or false.

true -> will save the form

false -> will do nothing

you can return the result of agreeDisagree function

function PreSaveAction(boolVal) {
	
            return agreeDisagree();
            
        }

but then you need to return true or false on agreeDisagree function

function agreeDisagree()
         {
         $j("#dialog").dialog({
                     title: "Terms & Conditions",
                     width: 450,
                     height: 280,
                     modal: true,
                     buttons: {
                         Agree: function () {
                           return true;
                         },
                    
                         Disagree: function () {
                           return false;
                         }
                     }
                 });
                 
         }

  • Proposed as answer by Rupesh Singh 14 hours 49 minutes ago
  • Unproposed as answer by NirajZ 14 hours 12 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2015 12:46pm

I tried this solution earlier and now also, but its not working.

One more thing, when a call goes to PreSaveAction, it also calls to agreeDisagree() and dont stop here. It just finish the whole cycle of validation. I debeg the script and found this .

PLease let me know 

July 29th, 2015 1:38pm

Just change this code,

function PreSaveAction() {
	var agDis = true;
            agDis = agreeDisagree();
return agDis;
            
        }
PreSaveAction should not take any input value.

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2015 2:13pm

still not working Rupesh
July 29th, 2015 2:23pm

Solved. Take asp.net button and hide default html one.

Now on client click of .net button call Pop up . From inside pop up call html click event. And solved.

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 2:12am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics