<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Totti&#039;s Blog &#187; vType</title>
	<atom:link href="http://iamtotti.com/blog/tag/vtype/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamtotti.com/blog</link>
	<description>Javascript, and front-end stuff.</description>
	<lastBuildDate>Tue, 24 Aug 2010 17:21:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ExtJS : 2 secs with custom vType</title>
		<link>http://iamtotti.com/blog/2009/12/extjs-2-secs-with-vtype/</link>
		<comments>http://iamtotti.com/blog/2009/12/extjs-2-secs-with-vtype/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 17:54:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[vType]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=95</guid>
		<description><![CDATA[Following another question on ExtJS forum, I&#8217;ve created a sample of how to use vType for ExtJS newbies. Basically, in form submission you need to validate user input and / or prevent user from entering invalid keys. Pure Javascript implementation could be quite a headache to some folks. ExtJS now provides a regex-based validation class [...]]]></description>
			<content:encoded><![CDATA[<p>Following another question on ExtJS forum, I&#8217;ve created a sample of how to use vType for ExtJS newbies.</p>
<p>Basically, in form submission you need to validate user input and / or prevent user from entering invalid keys. Pure Javascript implementation could be quite a headache to some folks. ExtJS now provides a regex-based validation class called, vType, which helps you to do both things mentioned above.</p>
<p>Demo:<a href="http://iamtotti.com/playground/js/ext-3.1.0/playground/vtype.html"> a simple Custom vType</a><br />
<span id="more-95"></span><br />
You can find more examples at <a href="http://www.extjs.com/deploy/dev/docs/?class=Ext.form.VTypes" target="_blank">ExtJS 3.1 API: vType<br />
</a></p>
<p>vType.js</p>
<pre class="brush: jscript;">
&lt;pre&gt;
Ext.onReady(function(){
	// QuickTips to display error messages next to form fields
	Ext.QuickTips.init();

	// Declare a custom VType
	Ext.apply(Ext.form.VTypes, {
                 // This function validates input text
		AlphaNum:  function(v) {
			return /^[a-z0-9]$/i.test(v);
		},
                // This is the tooltip message displayed when invalid input occurs
		AlphaNumText: 'Must be an alphanumeric word',
                // This mask filter invalid keystrokes
		AlphaNumMask: /[a-z0-9]/i
	});

	// Simple form with a text field for demo purpose
	var myForm = new Ext.FormPanel({
		width: 300,
		renderTo: Ext.getBody(),
		title: '2 secs with vType Demo',
		items: [
			{
				xtype: 'textfield',
				id: 'alphanum',
				fieldLabel: 'AlphaNum',
				vtype: 'AlphaNum'
			}
		],
		buttons: [
			{
				text: 'Submit',
				handler: function() {
					// myForm.getForm().submit();
					Ext.Msg.alert('Action', 'Form submitted');
				}
			}, {
				text: 'Reset',
				handler: function() {
					myForm.getForm().reset();
				}
			}
		]
	});
});
&lt;/pre&gt;
</pre>
<p>vType.html</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;ExtJS - VTypes&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../resources/css/ext-all.css&quot; /&gt;
	&lt;script src=&quot;../adapter/ext/ext-base.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script src=&quot;../ext-all.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

	&lt;script src=&quot;js/vtype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You need to know a little bit of javascript regular expression in order to configure vType as you want.</p>
<p>Happy coding,</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2009/12/extjs-2-secs-with-vtype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
