1

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?

1

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!

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.