跳到主要内容

SetRegularExp

设置文本小部件的正则验证表达式。

语法

expression.SetRegularExp(regularExpression);

expression - 表示 ApiTextWidget 类的变量。

参数

名称必需/可选数据类型默认值描述
regularExpression必需string验证正则表达式。

返回值

boolean

示例

定义 PDF 文本字段中允许的文本模式。

// How do I set a pattern that text must match in a text field in a PDF?

// Restrict text input to a specific format in a form field in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let comboboxField = Api.CreateComboboxField([10, 10, 160, 30]);
page.AddObject(comboboxField);

let widgets = comboboxField.GetAllWidgets();
widgets[0].SetRegularExp('\S+@\S+\.\S+');