1 <div class="body-wrap" xmlns:ext="http://www.extjs.com"><div class="top-tools"><a class="inner-link" href="#Ext.form.VTypes-props"><img src="resources/images/default/s.gif" class="item-icon icon-prop">Properties</a> <a class="inner-link" href="#Ext.form.VTypes-methods"><img src="resources/images/default/s.gif" class="item-icon icon-method">Methods</a> <a class="inner-link" href="#Ext.form.VTypes-events"><img src="resources/images/default/s.gif" class="item-icon icon-event">Events</a> <a class="bookmark" href="../docs/?class=Ext.form.VTypes"><img src="resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a> </div><h1>Class <a href="source/VTypes.html#cls-Ext.form.VTypes">Ext.form.VTypes</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.form</td></tr><tr><td class="label">Defined In:</td><td class="hd-info"><a href="source/VTypes.html#cls-Ext.form.VTypes">VTypes.js</a></td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/VTypes.html#cls-Ext.form.VTypes">VTypes</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr></table><div class="description"><p>This is a singleton object which contains a set of commonly used field validation functions.
2 The validations provided are basic and intended to be easily customizable and extended.</p>
3 <p>To add custom VTypes specify the <code><a href="output/Ext.form.TextField.html#Ext.form.TextField-vtype" ext:member="vtype" ext:cls="Ext.form.TextField">vtype</a></code> validation
4 test function, and optionally specify any corresponding error text to display and any keystroke
5 filtering mask to apply. For example:</p>
6 <pre><code><i>// custom Vtype <b>for</b> vtype:<em>'time'</em></i>
7 <b>var</b> timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
8 Ext.apply(Ext.form.VTypes, {
9 <i>// vtype validation <b>function</b></i>
10 time: <b>function</b>(val, field) {
11 <b>return</b> timeTest.test(val);
13 <i>// vtype Text property: The error text to display when the validation <b>function</b> returns false</i>
14 timeText: <em>'Not a valid time. Must be <b>in</b> the format <em>"12:34 PM"</em>.'</em>,
15 <i>// vtype Mask property: The keystroke filter mask</i>
16 timeMask: /[\d\s:amp]/i
19 <pre><code><i>// custom Vtype <b>for</b> vtype:<em>'IPAddress'</em></i>
20 Ext.apply(Ext.form.VTypes, {
21 IPAddress: <b>function</b>(v) {
22 <b>return</b> /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
24 IPAddressText: <em>'Must be a numeric IP address'</em>,
25 IPAddressMask: /[\d\.]/i
26 });</code></pre><br><br><i>This class is a singleton and cannot be created directly.</i></div><div class="hr"></div><a id="Ext.form.VTypes-props"></a><h2>Public Properties</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Property</th><th class="msource-header">Defined By</th></tr><tr class="property-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-alphaMask"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-alphaMask">alphaMask</a></b> : RegExp<div class="mdesc">The keystroke filter mask to be applied on alpha input. Defaults to:
27 <tt>/[a-z_]/i</tt></div></td><td class="msource">VTypes</td></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-alphaText"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-alphaText">alphaText</a></b> : String<div class="mdesc"><div class="short">The error text to display when the alpha validation function returns false. Defaults to:
28 'This field should only con...</div><div class="long">The error text to display when the alpha validation function returns false. Defaults to:
29 <tt>'This field should only contain letters and _'</tt></div></div></td><td class="msource">VTypes</td></tr><tr class="property-row "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-alphanumMask"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-alphanumMask">alphanumMask</a></b> : RegExp<div class="mdesc">The keystroke filter mask to be applied on alphanumeric input. Defaults to:
30 <tt>/[a-z0-9_]/i</tt></div></td><td class="msource">VTypes</td></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-alphanumText"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-alphanumText">alphanumText</a></b> : String<div class="mdesc"><div class="short">The error text to display when the alphanumeric validation function returns false. Defaults to:
31 'This field should o...</div><div class="long">The error text to display when the alphanumeric validation function returns false. Defaults to:
32 <tt>'This field should only contain letters, numbers and _'</tt></div></div></td><td class="msource">VTypes</td></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-emailMask"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-emailMask">emailMask</a></b> : RegExp<div class="mdesc"><div class="short">The keystroke filter mask to be applied on email input. See the email method for
33 information about more complex emai...</div><div class="long">The keystroke filter mask to be applied on email input. See the <a href="output/Ext.form.VTypes.html#Ext.form.VTypes-email" ext:member="email" ext:cls="Ext.form.VTypes">email</a> method for
34 information about more complex email validation. Defaults to:
35 <tt>/[a-z0-9_\.\-@]/i</tt></div></div></td><td class="msource">VTypes</td></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-emailText"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-emailText">emailText</a></b> : String<div class="mdesc"><div class="short">The error text to display when the email validation function returns false. Defaults to:
36 'This field should be an e-...</div><div class="long">The error text to display when the email validation function returns false. Defaults to:
37 <tt>'This field should be an e-mail address in the format "user@example.com"'</tt></div></div></td><td class="msource">VTypes</td></tr><tr class="property-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-urlText"></a><b><a href="source/VTypes.html#prop-Ext.form.VTypes-urlText">urlText</a></b> : String<div class="mdesc"><div class="short">The error text to display when the url validation function returns false. Defaults to:
38 'This field should be a URL i...</div><div class="long">The error text to display when the url validation function returns false. Defaults to:
39 <tt>'This field should be a URL in the format "http:/'+'/www.example.com"'</tt></div></div></td><td class="msource">VTypes</td></tr></tbody></table><a id="Ext.form.VTypes-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-alpha"></a><b><a href="source/VTypes.html#method-Ext.form.VTypes-alpha">alpha</a></b>( <code>String value</code> )
41 Boolean<div class="mdesc"><div class="short">The function used to validate alpha values</div><div class="long">The function used to validate alpha values<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The value</div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc">true if the RegExp test passed, and false if not.</div></li></ul></div></div></div></td><td class="msource">VTypes</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-alphanum"></a><b><a href="source/VTypes.html#method-Ext.form.VTypes-alphanum">alphanum</a></b>( <code>String value</code> )
43 Boolean<div class="mdesc"><div class="short">The function used to validate alphanumeric values</div><div class="long">The function used to validate alphanumeric values<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The value</div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc">true if the RegExp test passed, and false if not.</div></li></ul></div></div></div></td><td class="msource">VTypes</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-email"></a><b><a href="source/VTypes.html#method-Ext.form.VTypes-email">email</a></b>( <code>String value</code> )
45 Boolean<div class="mdesc"><div class="short">The function used to validate email addresses. Note that this is a very basic validation -- complete
46 validation per ...</div><div class="long">The function used to validate email addresses. Note that this is a very basic validation -- complete
47 validation per the email RFC specifications is very complex and beyond the scope of this class, although
48 this function can be overridden if a more comprehensive validation scheme is desired. See the validation
49 section of the <a href="http://en.wikipedia.org/wiki/E-mail_address">Wikipedia article on email addresses</a>
50 for additional information. This implementation is intended to validate the following emails:<tt>
51 'barney@example.de', 'barney.rubble@example.com', 'barney-rubble@example.coop', 'barney+rubble@example.com'
52 </tt>.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The email address</div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc">true if the RegExp test passed, and false if not.</div></li></ul></div></div></div></td><td class="msource">VTypes</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.form.VTypes-url"></a><b><a href="source/VTypes.html#method-Ext.form.VTypes-url">url</a></b>( <code>String value</code> )
54 Boolean<div class="mdesc"><div class="short">The function used to validate URLs</div><div class="long">The function used to validate URLs<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>value</code> : String<div class="sub-desc">The URL</div></li></ul><strong>Returns:</strong><ul><li><code>Boolean</code><div class="sub-desc">true if the RegExp test passed, and false if not.</div></li></ul></div></div></div></td><td class="msource">VTypes</td></tr></tbody></table><a id="Ext.form.VTypes-events"></a><h2>Public Events</h2><div class="no-members">This class has no public events.</div></div>