Question

I am working on SharePoint office 365 (2016), and facing issue while adding custom validation in new item form.
Here scenario is complex, I can't handle by using Validation setting/formula. So I have choose custom JavaScript code.
As validation should be perform on click of Save button and PreSaveAction method successfully called but only in 'Classic Experience' but when user changed to 'New Experience' it won't call because of change of HTML structure of the form.
Does any one have an idea how to fix this issue? Thanks in advance!

Was it helpful?

Solution

Modern (New) Experiences do not allow any custom scripting, branding or modifications.

Cast your vote here to tell Microsoft they made a mistake:

https://sharepoint.uservoice.com/forums/329214-sites-and-collaboration/suggestions/13385364-allow-javascript-customization-and-css-branding-th

OTHER TIPS

Try using PreSaveItem function. It is called when onClick event handler is fired for Save button in List Forms.

PreSaveItem function:

function PreSaveItem()
{   
   if ("function"==typeof(PreSaveAction))
   {
      return PreSaveAction();
   }
   return true;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top