Question

I'd like to hide 'Multiple Lines of Text' (Enhanced Rich Text) field if it's empty, if isn't empty -> show (both for New form & Edit form).

My code:

 
 if($("input[title^='EnhancedRichTextFieldName']").val() == ""){
    $('nobr:contains("EnhancedRichTextFieldName")').closest('tr').hide()
  } else {
    $('nobr:contains("EnhancedRichTextFieldName")').closest('tr').show();
         }  

It isn't working and I can't find why. I also tried the 'textarea' tag which should be AFAIK only for the 'Plain Text Field' and it also works perfectly for any other types of fields e.g. 'Single Line of Text', 'Multiple Lines of Text (Plain Text)', Choice (drop-down):

if($("input[title^='SingleLineOfTextFieldName']").val() == "")
if($("textarea[title^='PlainTextFieldName']").val() == "")
if($("select[title^='DropDownName']").val() == "") //+ change function

Any idea how to make it works for the Enhanced Rich Text?

Many thanks!

Was it helpful?

Solution

SharePoint does not create input or textarea for Multiple lines of text(enhanced rich text) field. all the contents of field are within the div. You can get that div by following selector:

var containingDiv = $("div[id^='MultiLineColName']");

So you can hide this div by applying CSS to "display:none" using jQuery.

I found similar question here and here. This may help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top