Using PreSaveAction() in NewForm.aspx in SharePoint list. RRS feed

  • Question

  • Hi,

    I using Content editor web part to for PreSaveAction() function in newform.aspx in SharePoint list. It works fine.

    But whenever I add reference to my jQuery file the PreSaveAction() event is not fired.

    Pls. help on this.



    Friday, September 28, 2012 9:23 AM


All replies

  • Hi AkashKale

    Are you use the  $j(document).ready()? If yes, Please delete it. The following is sample code

    <script type="text/javascript">
     var $j = jQuery.noConflict(); 
     function PreSaveAction() { 
       var txtStatus = $j(":input[title='Status']").val(); 
       if(txtStatus == "In Progress"){        
       alert("Invalid Status");        
       var statusfocus = $j(":input[title='Status']");        
       statusfocus .focus();        
       return false;}
       return true;

    You can refer to the following link.




    • Edited by Jack-Gao Monday, October 1, 2012 7:14 AM
    • Marked as answer by star.wars Friday, October 5, 2012 8:45 AM
    Monday, October 1, 2012 7:12 AM
  • Dear Jack (and all) --

    I have tried using PreSaveAction with and without document.ready and neither is working for me.

    This is my code...

    alert('Found me.'); //Does show.

    function PreSaveAction() { alert("Found PreSaveAction."); //Does NOT show. return false; }

    Do you have any suggestions?

    -- Mark Kamoski

    Tuesday, November 18, 2014 2:12 PM
  • Well there is no nee to delete document.ready , Just add if (!PreSaveItem()) return false; in your button to save item.

    Changed to - <input type="button" value="Save" name="btnSave" onclick="if (!PreSaveItem()) return false; {ddwrt:GenFireServerEvent('__commit;__redirect={home.aspx}')}" />

    Source : http://social.technet.microsoft.com/wiki/contents/articles/31330.sharepoint-using-presaveaction-function-on-custom-list-forms.aspx

    http://www.abdulazizfarooqi.wordpress.com Abdul Aziz Farooqi [BizTalk &amp;amp; SharePoint Consultant] MCPD Web &amp;amp; MCPD SharePoint 2010

    Monday, June 20, 2016 9:28 AM
  • Hi, 

    Please refer below link for presaveaction function -


    • Proposed as answer by Sidharth Tiwari Saturday, September 9, 2017 6:08 AM
    Sunday, August 6, 2017 6:51 AM
  • Hello Akash, I am trying to call a webservice in PresaveAction() function. This function return always default boolean value. It is not waiting till the service returns the data. 

    I want to check the duplicate items in the List. I am calling a REST and querying the list in PreSaveAction() method. But this function executes before REST response. 

    Please can you help me on this? How to hold the return value till the response come and validate the duplicate item.

    Vijay | http://www.csdiscussions.com

    Thursday, September 7, 2017 6:53 AM