Ext.apply(Ext.form.VTypes,
{
password: function(val, field)
{
if (field.initialPassField)
{
var pwd = Ext.get(field.initialPassField);
return (val == pwd.getValue());
}
return true;
},
passwordText: '两次输入的密码不一致!',
chinese:function(val,field)
{
var reg = /^[\u4e00-\u9fa5]+$/i;
if(!reg.test(val))
{
return false;
}
return true;
},
chineseText:'请输入中文',
age:function(val,field)
{
try
{
if(parseInt(val) >= 18 && parseInt(val) <= 100)
return true;
return false;
}
catch(err)
{
return false;
}
},
ageText:'年龄输入有误',
alphanum:function(val,field)
{
try
{
if(!/\W/.test(val))
return true;
46. return false;
47. }
48. catch(e)
49. {
50. return false;
51. }
52. },
53. alphanumText:'请输入英文字母或是数字,其它字符是不允许的.',
54.
55. url:function(val,field)
56. {
57. try
58. {
59. if(/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(val))
60. return true;
61. return false;
62. }
63. catch(e)
64. {
65. return false;
66. }
67. },
68. urlText:'请输入有效的URL地址.',
69.
70. max:function(val,field)
71. {
72. try
73. {
74. if(parseFloat(val) <= parseFloat(field.max))
75. return true;
76. return false;
77. }
78. catch(e)
79. {
80. return false;
81. }
82. },
83. maxText:'超过最大值',
84.
85. min:function(val,field)
86. {
87. try
88. {
89. if(parseFloat(val) >= parseFloat(field.min))
90. return true;
91. return false;
92. }
93. catch(e)
94. {
95. return false;
96. }
97. },
98. minText:'小于最小值',
99.
100. datecn:function(val,field)
101. {
102. try
103. {
104. var regex = /^(\d{4})-(\d{2})-(\d{2})$/;
105. if(!regex.test(val)) return false;
106. var d = new Date(val.replace(regex, '$1/$2/$3'));
107. return (parseInt(RegExp.$2, 10) == (1+d.getMonth())) && (parseInt(RegExp.$3, 10) == d.getDate())&&(parseInt(RegExp.$1, 10) == d.getFullYear());
108. }
109. catch(e)
110. {
111. return false;
112. }
113. },
114. datecnText:'请使用这样的日期格式: yyyy-mm-dd. 例如:2008-06-20.',
115.
116. integer:function(val,field)
117. {
118. try
119. {
120. if(/^[-+]?[\d]+$/.test(val))
121. return true;
122. return false;
123. }
124. catch(e)
125. {
126. return false;
127. }
128. },
129. integerText:'请输入正确的整数',
130.
131. minlength:function(val,field)
132. {
133. try
134. {
135. if(val.length >= parseInt(field.minlen))
136. return true;
137. return false
138. }
139. catch(e)
140. {
141. return false;
142. }
143. },
144. minlengthText:'长度过小',
145.
146. maxlength:function(val,field)
147. {
148. try
149. {
150. if(val.length <= parseInt(field.maxlen))
151. return true;
152. return false;
153. }
154. catch(e)
155. {
156. return false;
157. }
158. },
159. maxlengthText:'长度过大',
160.
161. ip:function(val,field)
162. {
163. try
164. {
165. if((/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(val)))
166. return true;
167. return false;
168. }
169. catch(e)
170. {
171. return false;
172. }
173. },
174. ipText:'请输入正确的IP地址',
175.
176. phone:function(val,field)
177. {
178. try
179. {
180. if(/^((0[1-9]{3})?(0[12][0-9])?[-])?\d{6,8}$/.test(val))
181. return true;
182. return false;
183. }
184. catch(e)
185. {
186. return false;
187. }
188. },
189. phoneText:'请输入正确的电话号码,如:0920-29392929',
190.
191. mobilephone:function(val,field)
192. {
193. try
194. {
195. if(/(^0?[1][35][0-9]{9}$)/.test(val))
196. return true;
197. return false;
198. }
199. catch(e)
200. {
201. return false;
202. }
203. },
204. mobilephoneText:'请输入正确的手机号码',
205.
206. alpha:function(val,field)
207. {
208. try
209. {
210. if( /^[a-zA-Z]+$/.test(val))
211. return true;
212. return false;
213. }
214. catch(e)
215. {
216. return false;
217. }
218. },
219. alphaText:'请输入英文字母'
220.});
{
password: function(val, field)
{
if (field.initialPassField)
{
var pwd = Ext.get(field.initialPassField);
return (val == pwd.getValue());
}
return true;
},
passwordText: '两次输入的密码不一致!',
chinese:function(val,field)
{
var reg = /^[\u4e00-\u9fa5]+$/i;
if(!reg.test(val))
{
return false;
}
return true;
},
chineseText:'请输入中文',
age:function(val,field)
{
try
{
if(parseInt(val) >= 18 && parseInt(val) <= 100)
return true;
return false;
}
catch(err)
{
return false;
}
},
ageText:'年龄输入有误',
alphanum:function(val,field)
{
try
{
if(!/\W/.test(val))
return true;
46. return false;
47. }
48. catch(e)
49. {
50. return false;
51. }
52. },
53. alphanumText:'请输入英文字母或是数字,其它字符是不允许的.',
54.
55. url:function(val,field)
56. {
57. try
58. {
59. if(/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(val))
60. return true;
61. return false;
62. }
63. catch(e)
64. {
65. return false;
66. }
67. },
68. urlText:'请输入有效的URL地址.',
69.
70. max:function(val,field)
71. {
72. try
73. {
74. if(parseFloat(val) <= parseFloat(field.max))
75. return true;
76. return false;
77. }
78. catch(e)
79. {
80. return false;
81. }
82. },
83. maxText:'超过最大值',
84.
85. min:function(val,field)
86. {
87. try
88. {
89. if(parseFloat(val) >= parseFloat(field.min))
90. return true;
91. return false;
92. }
93. catch(e)
94. {
95. return false;
96. }
97. },
98. minText:'小于最小值',
99.
100. datecn:function(val,field)
101. {
102. try
103. {
104. var regex = /^(\d{4})-(\d{2})-(\d{2})$/;
105. if(!regex.test(val)) return false;
106. var d = new Date(val.replace(regex, '$1/$2/$3'));
107. return (parseInt(RegExp.$2, 10) == (1+d.getMonth())) && (parseInt(RegExp.$3, 10) == d.getDate())&&(parseInt(RegExp.$1, 10) == d.getFullYear());
108. }
109. catch(e)
110. {
111. return false;
112. }
113. },
114. datecnText:'请使用这样的日期格式: yyyy-mm-dd. 例如:2008-06-20.',
115.
116. integer:function(val,field)
117. {
118. try
119. {
120. if(/^[-+]?[\d]+$/.test(val))
121. return true;
122. return false;
123. }
124. catch(e)
125. {
126. return false;
127. }
128. },
129. integerText:'请输入正确的整数',
130.
131. minlength:function(val,field)
132. {
133. try
134. {
135. if(val.length >= parseInt(field.minlen))
136. return true;
137. return false
138. }
139. catch(e)
140. {
141. return false;
142. }
143. },
144. minlengthText:'长度过小',
145.
146. maxlength:function(val,field)
147. {
148. try
149. {
150. if(val.length <= parseInt(field.maxlen))
151. return true;
152. return false;
153. }
154. catch(e)
155. {
156. return false;
157. }
158. },
159. maxlengthText:'长度过大',
160.
161. ip:function(val,field)
162. {
163. try
164. {
165. if((/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(val)))
166. return true;
167. return false;
168. }
169. catch(e)
170. {
171. return false;
172. }
173. },
174. ipText:'请输入正确的IP地址',
175.
176. phone:function(val,field)
177. {
178. try
179. {
180. if(/^((0[1-9]{3})?(0[12][0-9])?[-])?\d{6,8}$/.test(val))
181. return true;
182. return false;
183. }
184. catch(e)
185. {
186. return false;
187. }
188. },
189. phoneText:'请输入正确的电话号码,如:0920-29392929',
190.
191. mobilephone:function(val,field)
192. {
193. try
194. {
195. if(/(^0?[1][35][0-9]{9}$)/.test(val))
196. return true;
197. return false;
198. }
199. catch(e)
200. {
201. return false;
202. }
203. },
204. mobilephoneText:'请输入正确的手机号码',
205.
206. alpha:function(val,field)
207. {
208. try
209. {
210. if( /^[a-zA-Z]+$/.test(val))
211. return true;
212. return false;
213. }
214. catch(e)
215. {
216. return false;
217. }
218. },
219. alphaText:'请输入英文字母'
220.});