gpt4 book ai didi

javascript - Extjs 远程组合验证问题

转载 作者:行者123 更新时间:2023-11-30 10:53:40 25 4
gpt4 key购买 nike

嗨, 我正在使用 extjs 3.2.1 库,我是 extjs 的新手,

I have implemented combobox with remote with filtering option in the form, i have added forceSelection(true) property to combo for validate the text with store collection and allowblank(false) to combo for enable form save button .

我的问题是 forceSelection 属性仅验证模糊事件上的控件并清除组合文本,如果用户在组合中输入无效文本,则启用保存按钮(因为我只检查了组合的 allowblank(false) ) 在表单中,当他点击保存按钮时,它会在组合中提交无效文本。

我也检查了 form 和 combo 的 isvalid() 方法,在保存事件中它也返回“true”。

我如何在这种特定情况下进行验证?

最佳答案

可能您可以重写 ComboBox 中的 validateValue 函数,如果 forceSelection 设置为 true,则根据存储检查字段的原始值,如下所示:

Ext.override(Ext.form.ComboBox, {

validateValue : function(value) {

var errs = this.getErrors(value);

if((value || value != "") && this.forceSelection){
var val = this.getRawValue(),
rec = this.findRecord(this.displayField, val);

if(!rec)
errs.push("Invalid Selection");
}

var error = errs[0];

if (error == undefined) {
return true;
} else {
this.markInvalid(error);
return false;
}
}

});

关于javascript - Extjs 远程组合验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3682613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com