使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
blockly >字段 >setValidator
Field.setValidator() 方法
为可编辑字段设置新的验证函数,或清除以前设置的验证器。
验证器函数会接受新字段值,并返回经过验证的值。经过验证的值可以是输入值、输入值的修改版本或 null(用于取消更改)。
如果函数不返回任何内容(或返回未定义的值),则新值会被认为是有效值。这样可以让字段使用经过验证的函数作为字段级更改事件通知。
Signature:
setValidator(handler: FieldValidator<T>): void;
参数
返回:
void
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],["The `setValidator()` method configures or removes a validation function for editable fields. This function, provided as a `handler`, receives the new field value and returns either a validated value, a modified value, or `null` to prevent the change. Returning nothing or `undefined` accepts the new value. The `handler` parameter can also be set to `null` to clear an existing validator. It takes a `FieldValidator` type and returns `void`.\n"],null,[]]