Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.form.field.VTypes.html
1 <!DOCTYPE html><html><head><title>Ext.form.field.VTypes | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.form.field.VTypes',
13         docClass: 'Ext.form.field.VTypes',
14         docReq: 'Ext.form.field.VTypes',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'VTypes.html#Ext-form.field.VTypes';
33     clsInfo = {"methods":["alpha","alphanum","email","url"],"cfgs":[],"properties":["alphaMask","alphaText","alphanumMask","alphanumText","emailMask","emailText","urlText"],"events":[],"subclasses":[]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/VTypes.html#Ext-form.field.VTypes" target="_blank">Ext.form.field.VTypes</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>This is a singleton object which contains a set of commonly used field validation functions.
38 The validations provided are basic and intended to be easily customizable and extended.</p>
39
40
41 <p>To add custom VTypes specify the <code><a href="Ext.form.field.Text.html#vtype" rel="Ext.form.field.Text#vtype" class="docClass">vtype</a></code> validation
42 test function, and optionally specify any corresponding error text to display and any keystroke
43 filtering mask to apply. For example:</p>
44
45
46 <pre class="prettyprint"><code>// custom Vtype for vtype:'time'
47 var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
48 Ext.apply(Ext.form.field.VTypes, {
49     //  vtype validation function
50     time: function(val, field) {
51         return timeTest.test(val);
52     },
53     // vtype Text property: The error text to display when the validation function returns false
54     timeText: 'Not a valid time.  Must be in the format "12:34 PM".',
55     // vtype Mask property: The keystroke filter mask
56     timeMask: /[\d\s:amp]/i
57 });
58 </code></pre>
59
60
61 <p>Another example:</p>
62
63 <pre class="prettyprint"><code>// custom Vtype for vtype:'IPAddress'
64 Ext.apply(Ext.form.field.VTypes, {
65     IPAddress:  function(v) {
66         return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
67     },
68     IPAddressText: 'Must be a numeric IP address',
69     IPAddressMask: /[\d\.]/i
70 });
71 </code></pre>
72
73 <div class="members"><div class="m-properties"><a name="properties"></a><div class="definedBy">Defined By</div><h3 class="prp p">Properties</h3><div id="property-alphaMask" class="member f ni"><a href="Ext.form.field.VTypes.html#property-alphaMask" rel="property-alphaMask" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphaMask" class="viewSource">view source</a></div><a name="alphaMask"></a><a name="property-alphaMask"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphaMask" class="cls expand">alphaMask</a><span> : RegExp</span></div><div class="description"><div class="short"><p>The keystroke filter mask to be applied on alpha input.  Defaults to:
74 <tt>/[a-z_]/i</tt></p>
75 </div><div class="long"><p>The keystroke filter mask to be applied on alpha input.  Defaults to:
76 <tt>/[a-z_]/i</tt></p>
77 </div></div></div><div id="property-alphaText" class="member ni"><a href="Ext.form.field.VTypes.html#property-alphaText" rel="property-alphaText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphaText" class="viewSource">view source</a></div><a name="alphaText"></a><a name="property-alphaText"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphaText" class="cls expand">alphaText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the alpha validation function returns false.  Defaults to:
78 'This field should only con...</div><div class="long"><p>The error text to display when the alpha validation function returns false.  Defaults to:
79 <tt>'This field should only contain letters and _'</tt></p>
80 </div></div></div><div id="property-alphanumMask" class="member ni"><a href="Ext.form.field.VTypes.html#property-alphanumMask" rel="property-alphanumMask" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphanumMask" class="viewSource">view source</a></div><a name="alphanumMask"></a><a name="property-alphanumMask"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphanumMask" class="cls expand">alphanumMask</a><span> : RegExp</span></div><div class="description"><div class="short"><p>The keystroke filter mask to be applied on alphanumeric input.  Defaults to:
81 <tt>/[a-z0-9_]/i</tt></p>
82 </div><div class="long"><p>The keystroke filter mask to be applied on alphanumeric input.  Defaults to:
83 <tt>/[a-z0-9_]/i</tt></p>
84 </div></div></div><div id="property-alphanumText" class="member ni"><a href="Ext.form.field.VTypes.html#property-alphanumText" rel="property-alphanumText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphanumText" class="viewSource">view source</a></div><a name="alphanumText"></a><a name="property-alphanumText"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphanumText" class="cls expand">alphanumText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the alphanumeric validation function returns false.  Defaults to:
85 'This field should o...</div><div class="long"><p>The error text to display when the alphanumeric validation function returns false.  Defaults to:
86 <tt>'This field should only contain letters, numbers and _'</tt></p>
87 </div></div></div><div id="property-emailMask" class="member ni"><a href="Ext.form.field.VTypes.html#property-emailMask" rel="property-emailMask" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-emailMask" class="viewSource">view source</a></div><a name="emailMask"></a><a name="property-emailMask"></a><a href="Ext.form.field.VTypes.html#" rel="property-emailMask" class="cls expand">emailMask</a><span> : RegExp</span></div><div class="description"><div class="short">The keystroke filter mask to be applied on email input.  See the email method for
88 information about more complex emai...</div><div class="long"><p>The keystroke filter mask to be applied on email input.  See the <a href="Ext.form.field.VTypes.html#email" rel="Ext.form.field.VTypes#email" class="docClass">email</a> method for
89 information about more complex email validation. Defaults to:
90 <tt>/[a-z0-9_.-@]/i</tt></p>
91 </div></div></div><div id="property-emailText" class="member ni"><a href="Ext.form.field.VTypes.html#property-emailText" rel="property-emailText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-emailText" class="viewSource">view source</a></div><a name="emailText"></a><a name="property-emailText"></a><a href="Ext.form.field.VTypes.html#" rel="property-emailText" class="cls expand">emailText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the email validation function returns false.  Defaults to:
92 'This field should be an e-...</div><div class="long"><p>The error text to display when the email validation function returns false.  Defaults to:
93 <tt>'This field should be an e-mail address in the format "user@example.com"'</tt></p>
94 </div></div></div><div id="property-urlText" class="member ni"><a href="Ext.form.field.VTypes.html#property-urlText" rel="property-urlText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-urlText" class="viewSource">view source</a></div><a name="urlText"></a><a name="property-urlText"></a><a href="Ext.form.field.VTypes.html#" rel="property-urlText" class="cls expand">urlText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the url validation function returns false.  Defaults to:
95 'This field should be a URL i...</div><div class="long"><p>The error text to display when the url validation function returns false.  Defaults to:
96 <tt>'This field should be a URL in the format "http:/'+'/www.example.com"'</tt></p>
97 </div></div></div></div><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-alpha" class="member f ni"><a href="Ext.form.field.VTypes.html#method-alpha" rel="method-alpha" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-alpha" class="viewSource">view source</a></div><a name="alpha"></a><a name="method-alpha"></a><a href="Ext.form.field.VTypes.html#" rel="method-alpha" class="cls expand">alpha</a>(
98 <span class="pre">String value</span>)
99  : Boolean</div><div class="description"><div class="short"><p>The function used to validate alpha values</p>
100 </div><div class="long"><p>The function used to validate alpha values</p>
101 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The value</p>
102 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
103 </li></ul></div></div></div><div id="method-alphanum" class="member ni"><a href="Ext.form.field.VTypes.html#method-alphanum" rel="method-alphanum" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-alphanum" class="viewSource">view source</a></div><a name="alphanum"></a><a name="method-alphanum"></a><a href="Ext.form.field.VTypes.html#" rel="method-alphanum" class="cls expand">alphanum</a>(
104 <span class="pre">String value</span>)
105  : Boolean</div><div class="description"><div class="short"><p>The function used to validate alphanumeric values</p>
106 </div><div class="long"><p>The function used to validate alphanumeric values</p>
107 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The value</p>
108 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
109 </li></ul></div></div></div><div id="method-email" class="member ni"><a href="Ext.form.field.VTypes.html#method-email" rel="method-email" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-email" class="viewSource">view source</a></div><a name="email"></a><a name="method-email"></a><a href="Ext.form.field.VTypes.html#" rel="method-email" class="cls expand">email</a>(
110 <span class="pre">String value</span>)
111  : Boolean</div><div class="description"><div class="short">The function used to validate email addresses.  Note that this is a very basic validation -- complete
112 validation per ...</div><div class="long"><p>The function used to validate email addresses.  Note that this is a very basic validation -- complete
113 validation per the email RFC specifications is very complex and beyond the scope of this class, although
114 this function can be overridden if a more comprehensive validation scheme is desired.  See the validation
115 section of the <a href="http://en.wikipedia.org/wiki/E-mail_address">Wikipedia article on email addresses</a>
116 for additional information.  This implementation is intended to validate the following emails:<tt>
117 'barney@example.de', 'barney.rubble@example.com', 'barney-rubble@example.coop', 'barney+rubble@example.com'
118 </tt>.</p>
119 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The email address</p>
120 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
121 </li></ul></div></div></div><div id="method-url" class="member ni"><a href="Ext.form.field.VTypes.html#method-url" rel="method-url" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-url" class="viewSource">view source</a></div><a name="url"></a><a name="method-url"></a><a href="Ext.form.field.VTypes.html#" rel="method-url" class="cls expand">url</a>(
122 <span class="pre">String value</span>)
123  : Boolean</div><div class="description"><div class="short"><p>The function used to validate URLs</p>
124 </div><div class="long"><p>The function used to validate URLs</p>
125 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The URL</p>
126 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
127 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>