Question

I am simply looking to use the PreSaveAction() in a content editor web part as an extra cautionary step prior to saving a list item.

Here is what I have:

function PreSaveAction()
{
alert('Are you sure you want to save this Profile?');
return true;
} 
</script>

How do I add a "Yes" and "No" button as opposed to the "ok" that pops up by default and use those to either go forward with the save or return back to the edit form?

Was it helpful?

Solution

A little bit of searching around got me this:

<script type="text/javascript">

 function PreSaveAction()
 {
 if (confirm('Are you sure you want to save this profile?')) 
 {
 return true;
 }
 else
 {
 return false;
 }
 } 
</script>

Credit to: https://stackoverflow.com/questions/9334636/javascript-yes-no-alert

Thanks!

OTHER TIPS

You could inject some markup into the page to show real buttons rather than a Confirm dialog pretty easily. It would make the UX a bit better.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top