⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vtypes.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
字号:
/*
 * Ext JS Library 3.0 Pre-alpha
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @class Ext.form.VTypes * <p>This is a singleton object which contains a set of commonly used field validation functions. * The validations provided are basic and intended to be easily customizable and extended.</p> * <p>To add custom VTypes specify the <tt>{@link Ext.form.TextField#vtype vtype}</tt> validation * test function, and optionally specify any corresponding error text to display and any keystroke * filtering mask to apply. For example:</p> * <pre><code>// custom Vtype for vtype:'time'var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;Ext.apply(Ext.form.VTypes, {    //  vtype validation function    time: function(val, field) {        return timeTest.test(val);    },    // vtype Text property: The error text to display when the validation function returns false    timeText: 'Not a valid time.  Must be in the format "12:34 PM".',    // vtype Mask property: The keystroke filter mask    timeMask: /[\d\s:amp]/i}); * </code></pre> * Another example:  * <pre><code>// custom Vtype for vtype:'IPAddress'Ext.apply(Ext.form.VTypes, {    IPAddress:  function(v) {        return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);    },    IPAddressText: 'Must be a numeric IP address',    IPAddressMask: /[\d\.]/i}); * </code></pre> * @singleton */Ext.form.VTypes = function(){    // closure these in so they are only created once.    var alpha = /^[a-zA-Z_]+$/;    var alphanum = /^[a-zA-Z0-9_]+$/;    var email = /^([\w]+)(\.[\w]+)*@([\w\-]+\.){1,5}([A-Za-z]){2,4}$/;    var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;    // All these messages and functions are configurable    return {        /**         * The function used to validate email addresses.  Note that this is a very basic validation -- complete         * validation per the email RFC specifications is very complex and beyond the scope of this class, although         * this function can be overridden if a more comprehensive validation scheme is desired.  See the validation         * section of the <a href="http://en.wikipedia.org/wiki/E-mail_address">Wikipedia article on email addresses</a>          * for additional information.         * @param {String} value The email address         */        'email' : function(v){            return email.test(v);        },        /**         * The error text to display when the email validation function returns false.  Defaults to:         * <tt>'This field should be an e-mail address in the format "user@domain.com"'</tt>         * @type String         */        'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',        /**         * The keystroke filter mask to be applied on email input.  See the {@link #email} method for          * information about more complex email validation. Defaults to:         * <tt>/[a-z0-9_\.\-@]/i</tt>         * @type RegExp         */        'emailMask' : /[a-z0-9_\.\-@]/i,        /**         * The function used to validate URLs         * @param {String} value The URL         */        'url' : function(v){            return url.test(v);        },        /**         * The error text to display when the url validation function returns false.  Defaults to:         * <tt>'This field should be a URL in the format "http:/'+'/www.domain.com"'</tt>         * @type String         */        'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',                /**         * The function used to validate alpha values         * @param {String} value The value         */        'alpha' : function(v){            return alpha.test(v);        },        /**         * The error text to display when the alpha validation function returns false.  Defaults to:         * <tt>'This field should only contain letters and _'</tt>         * @type String         */        'alphaText' : 'This field should only contain letters and _',        /**         * The keystroke filter mask to be applied on alpha input.  Defaults to:         * <tt>/[a-z_]/i</tt>         * @type RegExp         */        'alphaMask' : /[a-z_]/i,        /**         * The function used to validate alphanumeric values         * @param {String} value The value         */        'alphanum' : function(v){            return alphanum.test(v);        },        /**         * The error text to display when the alphanumeric validation function returns false.  Defaults to:         * <tt>'This field should only contain letters, numbers and _'</tt>         * @type String         */        'alphanumText' : 'This field should only contain letters, numbers and _',        /**         * The keystroke filter mask to be applied on alphanumeric input.  Defaults to:         * <tt>/[a-z0-9_]/i</tt>         * @type RegExp         */        'alphanumMask' : /[a-z0-9_]/i    };}();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -