2 * @example Form Validation
5 Ext.require('Ext.form.Panel');
6 Ext.require('Ext.form.field.Date');
7 Ext.onReady(function() {
9 var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
10 Ext.apply(Ext.form.field.VTypes, {
11 // vtype validation function
12 time: function(val, field) {
13 return timeTest.test(val);
15 // vtype Text property: The error text to display when the validation function returns false
16 timeText: 'Not a valid time. Must be in the format "12:34 PM".',
17 // vtype Mask property: The keystroke filter mask
18 timeMask: /[\d\s:amp]/i
21 Ext.create('Ext.form.Panel', {
22 renderTo: Ext.getBody(),
27 defaultType: 'textfield',
30 fieldLabel: 'First Name',
34 fieldLabel: 'Last Name',
38 fieldLabel: 'Email Address',
44 fieldLabel: 'Date of Birth',
46 msgTarget: 'under', // location of the error message
47 invalidText: '"{0}" bad. "{1}" good.' // custom error message
50 fieldLabel: 'Last Login Time',
52 vtype: 'time' // using a custom validation type