我想检查数据库中是否存在文本字段的内容,所以我定义了一个 VTypes:
Ext.apply( Ext.form.field.VTypes,{
sampleSetExist: function(val, field) {
alert('triggered');
var result;
Ext.Ajax.request({
url: 'sampleSetExist.action',
params: {
name:val
},
async:false,
success: function(response){
var res = response.responseText;
var jsonObject = Ext.decode( res );
if( jsonObject.exist == true )
result = false;
else
result = true;
}
});
return result;
}
});
和这样的文本字段:
{
fieldLabel: 'Name',
itemId: 'sampleSetName',
name: 'ssi.name',
allowBlank: false,
validateOnBlur: true,
validateOnChange: false,
vtype: 'sampleSetExist',
vtypeText: 'The name has exist!'
}
……
当textfield模糊时,验证器函数sampleSetExist会被触发3次。为什么会出现这种情况?