1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | // Add the additional 'advanced' VTypes |
---|
10 | Ext.apply(Ext.form.VTypes, { |
---|
11 | daterange : function(val, field) { |
---|
12 | var date = field.parseDate(val); |
---|
13 | |
---|
14 | if(!date){ |
---|
15 | return; |
---|
16 | } |
---|
17 | if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) { |
---|
18 | var start = Ext.getCmp(field.startDateField); |
---|
19 | start.setMaxValue(date); |
---|
20 | start.validate(); |
---|
21 | this.dateRangeMax = date; |
---|
22 | } |
---|
23 | else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) { |
---|
24 | var end = Ext.getCmp(field.endDateField); |
---|
25 | end.setMinValue(date); |
---|
26 | end.validate(); |
---|
27 | this.dateRangeMin = date; |
---|
28 | } |
---|
29 | /* |
---|
30 | * Always return true since we're only using this vtype to set the |
---|
31 | * min/max allowed values (these are tested for after the vtype test) |
---|
32 | */ |
---|
33 | return true; |
---|
34 | }, |
---|
35 | |
---|
36 | password : function(val, field) { |
---|
37 | if (field.initialPassField) { |
---|
38 | var pwd = Ext.getCmp(field.initialPassField); |
---|
39 | return (val == pwd.getValue()); |
---|
40 | } |
---|
41 | return true; |
---|
42 | }, |
---|
43 | |
---|
44 | passwordText : 'Passwords do not match' |
---|
45 | }); |
---|
46 | |
---|
47 | Ext.onReady(function(){ |
---|
48 | |
---|
49 | Ext.QuickTips.init(); |
---|
50 | |
---|
51 | // turn on validation errors beside the field globally |
---|
52 | Ext.form.Field.prototype.msgTarget = 'side'; |
---|
53 | |
---|
54 | var bd = Ext.getBody(); |
---|
55 | |
---|
56 | /* |
---|
57 | * ================ Date Range ======================= |
---|
58 | */ |
---|
59 | |
---|
60 | var dr = new Ext.FormPanel({ |
---|
61 | labelWidth: 125, |
---|
62 | frame: true, |
---|
63 | title: 'Date Range', |
---|
64 | bodyStyle:'padding:5px 5px 0', |
---|
65 | width: 350, |
---|
66 | defaults: {width: 175}, |
---|
67 | defaultType: 'datefield', |
---|
68 | items: [{ |
---|
69 | fieldLabel: 'Start Date', |
---|
70 | name: 'startdt', |
---|
71 | id: 'startdt', |
---|
72 | vtype: 'daterange', |
---|
73 | endDateField: 'enddt' // id of the end date field |
---|
74 | },{ |
---|
75 | fieldLabel: 'End Date', |
---|
76 | name: 'enddt', |
---|
77 | id: 'enddt', |
---|
78 | vtype: 'daterange', |
---|
79 | startDateField: 'startdt' // id of the start date field |
---|
80 | }] |
---|
81 | }); |
---|
82 | |
---|
83 | dr.render('dr'); |
---|
84 | |
---|
85 | /* |
---|
86 | * ================ Password Verification ======================= |
---|
87 | */ |
---|
88 | |
---|
89 | var pwd = new Ext.FormPanel({ |
---|
90 | labelWidth: 125, |
---|
91 | frame: true, |
---|
92 | title: 'Password Verification', |
---|
93 | bodyStyle:'padding:5px 5px 0', |
---|
94 | width: 350, |
---|
95 | defaults: { |
---|
96 | width: 175, |
---|
97 | inputType: 'password' |
---|
98 | }, |
---|
99 | defaultType: 'textfield', |
---|
100 | items: [{ |
---|
101 | fieldLabel: 'Password', |
---|
102 | name: 'pass', |
---|
103 | id: 'pass' |
---|
104 | },{ |
---|
105 | fieldLabel: 'Confirm Password', |
---|
106 | name: 'pass-cfrm', |
---|
107 | vtype: 'password', |
---|
108 | initialPassField: 'pass' // id of the initial password field |
---|
109 | }] |
---|
110 | }); |
---|
111 | |
---|
112 | pwd.render('pw'); |
---|
113 | }); |
---|