SP 2013: PreSaveAction validation of Enterprise Keywords column
-
01-01-2021 - |
문제
In my list, I am validating a lot of columns using the PreSaveAction. I have many look-up columns that I want to be required and the OOTB required field way doesn't cut it.
OK - that's cool. I have all my fields validating, EXCEPT for Enterprise Keywords. No matter what I try, it won't work.
I use the the following in the console: $("div[title='Enterprise Keywords']").find("div[role='textbox']").text();
The output was: "" //the same was true for .val() and .html().
Then, I do: var valEntKeywords = $("div[title='Enterprise Keywords']").find("div[role='textbox']").text();
valEntKeywords == ""; And, the output is: false
Any ideas on how to successfully validate the Enterprise Keywords column with PreSaveAction()?
해결책 2
So, there's a "hidden" input field associated with it.
For my application, since I only had to worry about one such form field, I was able to validate against:
$("input[id^='TaxKeyword_']").val();
다른 팁
Usually there is a unicode character which represents a zero width space. Try this.
$("div[title='Enterprise Keywords']").find("div[role='textbox']").text().replace(/[\u200B-\u200D\uFEFF]/g, '') == ""