跳到主要内容

SetAllowedSymbols

设置当前文本字段允许的符号。只接受指定的字符作为输入。

语法

expression.SetAllowedSymbols(symbols);

expression - 表示 ApiTextForm 类的变量。

参数

名称必需/可选数据类型默认值描述
symbols必需string允许的字符字符串。

返回值

boolean

示例

限制文档中的文本字段仅接受特定的字符集。

// How do I limit which characters a user can type into a text field in a document?

// Prevent unwanted input by defining the exact characters allowed in a text field in a document.

let doc = Api.GetDocument();
let textForm = Api.CreateTextForm({ key: "Digits", placeholder: "Digits only" });
textForm.SetAllowedSymbols("0123456789");
let paragraph = doc.GetElement(0);
paragraph.AddText("Text form accepting digits only: ");
paragraph.Push(textForm);