SharePoint 2003 PreSaveAction() to make attachment required
-
09-12-2019 - |
Question
I asked this question in the main SOF forum but I think it belongs here.
https://stackoverflow.com/questions/10415929/sharepoint-2003-presaveaction
I need to add a little JavaScript to run when user clicks "Save and Close". I know in SharePoint 2010 I could just use PreSaveAction() but I am using 2003.
Pseudo:
user clicks save and close
if attachment exists
add the list entry
else
alert the user to upload attachment
It looks like the function ClickOnce() is what triggers the form to save since the button href="javascript:ClickOnce()"
. So what I did was change the href of this link to my own function unless attachment exists. This did not work because it would either do nothing or fire when the page loaded whether there was an attachment or not.
Anyone have a workaround for this?
Solution
You could use jQuery to change the HREF on the save button to first call your javascript and then call the ClickOnce() function.
Something like:
href="javascript:YourFunction();ClickOnce();"