extjs 验证 OR config options 外部设置 。。。
在用extjs 如何异步(ext.ajax.request)验证提交数据中,和数据库中无重复值。
我通过apply 定义了 vtype 类似例子:
/*
* Ext JS Library 2.1
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
*http://extjs.com/license
*/
// Add the additional 'advanced' VTypes
Ext.apply(Ext.form.VTypes, {
password: function(val, field) {
if (field.initialPassField) {
var pwd = Ext.getCmp(field.initialPassField);
return (val == pwd.getValue());
}
return true;
},
passwordText: 'Passwords do not match'
});
Ext.onReady(function(){
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var bd = Ext.getBody();
/*
* ================ Date Range =======================
*/
var pwd = new Ext.FormPanel({
labelWidth: 125,
frame: true,
title: 'Password Verification',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {
width: 175,
inputType: 'password'
},
defaultType: 'textfield',
items: [{
fieldLabel: 'Password',
name: 'pass',
id: 'pass'
},{
fieldLabel: 'Confirm Password',
name: 'pass-cfrm',
vtype: 'password',
initialPassField: 'pass' // id of the initial password field
}]
});
pwd.render(bd);
});
我在其中加了异步请求服务的内容,查询是否有该记录,但是返回的success 中怎么样VTypes return true 或 false啊?
异步的值没法赋值啊, 在success:中返回不可以。
我又在textfield 中 做监听 可是返回的值也没办法 配置到 textfield 中的 config options 中,
晕了 忙一下午了,说的挺乱,那位兄弟提供一个有后台的验证不可以重复值的例子。