透過集合功能整理內容
你可以依據偏好儲存及分類內容。
封鎖 >欄位 >setValidator
Field.setValidator() 方法
為可編輯的欄位設定新的驗證函式,或清除先前設定的驗證工具。
驗證工具使用新欄位值,並傳回已驗證的值。驗證的值可以是輸入值、輸入值的修改版本,或是 null 來取消變更。
如果函式未傳回任何值 (或傳回未定義),則會接受新值。如果欄位使用已驗證的函式做為欄位層級變更事件通知,即可使用這類通知。
Signature:
setValidator(handler: FieldValidator<T>): void;
參數
傳回:
void
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間: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,[]]