문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top