跳到主要内容

Keyword match in form keys

Highlights form fields based on a keyword match in the form key.

(function () {
let keyword = "information";
let caseInsensitive = true; // Set to true for case-insensitive search, false for case-sensitive
let enableRequired = true; // Set to true to enable 'required' property when keyword is found, false to disable

let regex = new RegExp(keyword, caseInsensitive ? "i" : "");

let doc = Api.GetDocument();
let forms = doc.GetAllForms();

for (let form of forms) {
let formKey = form.GetFormKey();
let isMatch = regex.test(formKey);
form.SetRequired(isMatch ? enableRequired : isMatch);
}
})();

Methods used: GetDocument, GetAllForms, GetFormKey, SetRequired

Result

KeywordMatch KeywordMatch