• 关于extjs field的校验


    最近项目需要用到对输入字段进行校验,翻看了EXTJS TextField的联机文档,里面有如下说明:

    Validates a value according to the field's validation rules and marks the field as invalid
         * if the validation fails. Validation rules are processed in the following order:


         *


           *
           *
    • 1. Field specific validator
           *


           *

      A validator offers a way to customize and reuse a validation specification.
           * If a field is configured with a {@link #validator}
           * function, it will be passed the current field value.  The {@link #validator}
           * function is expected to return either:
           *


             *
      • Boolean true if the value is valid (validation continues).
             *
      • a String to represent the invalid message if invalid (validation halts).
             *


           *


           *
           *
    • 2. Basic Validation
           *


           *

      If the {@link #validator} has not halted validation,
           * basic validation proceeds as follows:


           *
           *


             *
             *
      • {@link #allowBlank} : (Invalid message =
             * {@link #emptyText})


             * Depending on the configuration of {@link #allowBlank}, a
             * blank field will cause validation to halt at this step and return
             * Boolean true or false accordingly. 
             *


             *
             *
      • {@link #minLength} : (Invalid message =
             * {@link #minLengthText})


             * If the passed value does not satisfy the {@link #minLength}
             * specified, validation halts.
             *


             *
             *
      • {@link #maxLength} : (Invalid message =
             * {@link #maxLengthText})


             * If the passed value does not satisfy the {@link #maxLength}
             * specified, validation halts.
             *


             *
             *


           *


           *
           *
    • 3. Preconfigured Validation Types (VTypes)
           *


           *

      If none of the prior validation steps halts validation, a field
           * configured with a {@link #vtype} will utilize the
           * corresponding {@link Ext.form.VTypes VTypes} validation function.
           * If invalid, either the field's {@link #vtypeText} or
           * the VTypes vtype Text property will be used for the invalid message.
           * Keystrokes on the field will be filtered according to the VTypes
           * vtype Mask property.


           *


           *
           *
    • 4. Field specific regex test
           *


           *

      If none of the prior validation steps halts validation, a field's
           * configured {@link #regex} test will be processed.
           * The invalid message for this test is configured with
           * {@link #regexText}.


           *


           *
           * @param {Mixed} value The value to validate
           * @return {Boolean} True if the value is valid, else false
           */
  • 相关阅读:
    C++ 虚函数表解析
    Zend Studio使用
    Java的位运算符具体解释实例——与(&)、非(~)、或(|)、异或(^)
    史上最简单的Hibernate入门简单介绍
    Ubuntu下很给力的下载工具
    hdu1698 Just a Hook 线段树:成段替换,总区间求和
    STL vector使用方法介绍
    Linux守护进程的编程实现
    PDO--PHP Data Objects
    经常使用的android弹出对话框
  • 原文地址:https://www.cnblogs.com/barryhong/p/1704470.html
Copyright © 2020-2023  润新知