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
3 Answers
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– Dave2018-03-22 23:26:10 +00:00Commented Mar 22, 2018 at 23:26
-
Ok, does this works, social.technet.microsoft.com/Forums/sharepoint/en-US/…Kasper Bo Larsen– Kasper Bo Larsen2018-03-22 23:31:20 +00:00Commented Mar 22, 2018 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– Jay2018-03-23 00:46:51 +00:00Commented Mar 23, 2018 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– Kasper Bo Larsen2018-03-23 10:59:48 +00:00Commented Mar 23, 2018 at 10:59
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');
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