Answered by:
Using PreSaveAction() in NewForm.aspx in SharePoint list.

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.
Thanks
Akash.
Friday, September 28, 2012 9:23 AM
Answers
-
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() { alert("here"); 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; } </script>
You can refer to the following link.
Thanks,
Jack
Monday, October 1, 2012 7:12 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() { alert("here"); 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; } </script>
You can refer to the following link.
Thanks,
Jack
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}')}"
/>
http://www.abdulazizfarooqi.wordpress.com Abdul Aziz Farooqi [BizTalk &amp; SharePoint Consultant] MCPD Web &amp; MCPD SharePoint 2010
- Proposed as answer by AbdulAzizFarooqi Monday, June 20, 2016 9:28 AM
Monday, June 20, 2016 9:28 AM -
Hi,
Please refer below link for presaveaction function -
http://sidteche.blogspot.in/2017/08/sharepoint-using-presaveaction-function.html
- 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