Class Ext.form.VTypes

Package:Ext.form
Defined In:VTypes.js
Class:VTypes
Extends:Object

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.

To add custom VTypes specify the vtype validation test function, and optionally specify any corresponding error text to display and any keystroke filtering mask to apply. For example:

// 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
});
Another example:
// 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
});


This class is a singleton and cannot be created directly.

Public Properties

PropertyDefined By
 alphaMask : RegExp
The keystroke filter mask to be applied on alpha input. Defaults to: /[a-z_]/i
VTypes
 alphanumMask : RegExp
The keystroke filter mask to be applied on alphanumeric input. Defaults to: /[a-z0-9_]/i
VTypes

Public Methods

MethodDefined By

Public Events

This class has no public events.