Prompting and Dirty Forms

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
DevinMcMahon1
Posts: 2
Joined: Sun Dec 02, 2018

02 Dec 2018

I have an existing application that is built on Forms Designer 3.1.5
The users have requested the ability to prevent accidental loss of entered data
I have spoken with SPFORM support about this and there is discouraging news about the ability to do this, based on modern browsers, with pop-ups etc.

So before I proceed on the following detailed solution, I would like someone to weigh in on it's viability. I have tested this solution in Edge, IE, Chrome, and Firefox and all the results are the same and positive, even though it does not show the actual message, all the browsers ask me if I am sure I want to leave, this is whenever I have a Dirty form and either close the tab, browse away or click Cancel which is the desired result. This app would only ever be accessed by internal personnel who are inside the network and the Site is trusted as an Intranet site.

Please review this and give me any feedback, because to me it seems like it works fine and meets my goals. and please be gentle, I am not a Javascript programmer by any stretch of the imagination I am only pitching in which is why I would not put this in production without feedback.

Thank you

JavaScript Editor:


window.isNotSaved = true;

isDirty = false;
var msg = 'Not Saved';
$(document).ready(function(){
$(':input').change(function(){
if(!isDirty){
isDirty = true;
}
});
window.onbeforeunload = function(){
if((isDirty) && window.isNotSaved) {

return msg;

}
};
});

OnClick Event of Save Button:

window.isNotSaved = false;

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

03 Dec 2018

Dear Devin,
I've deleted one of the 2 posts, since they were exact copies of each other, but the question is good. I believe that there is no harm in using this method, it's just that we cannot guarantee that it will always work, so we do not recommend relying on it 100%

But it is definitely better than nothing, so if it is something that you need and it meets your goals, you can absolutely use it.

Hope it helps!
Cheers

User avatar
DevinMcMahon1
Posts: 2
Joined: Sun Dec 02, 2018

03 Dec 2018

Thank you, sorry for double-post.

Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests