1、Extjs 面板
xtype:'textfield',
name:'ucode',
id:'ucode',
fieldLabel:'登入名称',
allowBlank:false,
blankText:'登入名称不能为空',
anchor:'90%',
validator: vlidateUcode,
invalidText:'用户名已经注册'
2、实现代码
var bool = false;
function vlidateUcode(val){
Ext.Ajax.request({
url: cxt + '/user/valiUserCode.do',
method: 'post',
waitTitle:'请等待',
async : true,
waitMsg: '正在提交...',
params:{ucode:val},
success: function(ret) {
var info = Ext.util.JSON.decode(ret.responseText);
if(info.success == 'true')
setValue(false);
else
setValue(true);
console.log(bool);
}
})
console.log(bool);
function setValue(retBool){
bool = retBool;
}
return bool;
}