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!

up vote 5 down vote accepted

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

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;
}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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