0

I'd like to set a richtext field to read-only via Javascript/JQuery. Would be great if it works at SP 2013, 2016 and SharePoint Online

1

I guess you want the field to become read only once the end user has enteded some Content? In that case the field should be read write in the New form and read only in the Edit form which can be done by inserting a tiny script in the Edit form

An example : https://www.c-sharpcorner.com/code/816/make-a-sharepoint-list-form-field-read-only-with-jquery.aspx

  • This is not working with a richt text field, since it is not an input... – Dave Mar 22 '18 at 23:26
  • Ok, does this works, social.technet.microsoft.com/Forums/sharepoint/en-US/… – Kasper Bo Larsen Mar 22 '18 at 23:31
  • Just remember you can edit list content in other ways. The edit form is not the only way so the content can still be changed. For example: "Quick edit" – Jay Mar 23 '18 at 0:46
  • True, but that can be disabled too. The requirement is kind of broard so NewForm could be a good starting point 😊 – Kasper Bo Larsen Mar 23 '18 at 10:59
0

Found it... there seems to be an additional property used by SharePoint scripts that enables and disables the field.

inputDivOBJ.find('[id$="inplacerte"]').prop('contenteditable','false');
0

SPUtility plugin does this job perfectly. Load SPUtility and run the following script inside document.ready

SPUtility.GetSPFieldByInternalName('InternalNameOfRichTextField').MakeReadOnly();

To make the field editable again use the following line

SPUtility.GetSPFieldByInternalName('InternalNameOfRichTextField').MakeEditable();

This functionality works only in forms not on Quick Edit Views like most JS validation solutions

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.