开发者

How to include field values in the vtypes message text for vtype validation in forms?

开发者 https://www.devze.com 2023-03-21 20:10 出处:网络
I\'m working on form validation and I have used Vtypes to check number ranges. It\'s all working fine, except I need to include my own allowed values ( fie开发者_StackOverflow中文版ld.minValField and

I'm working on form validation and I have used Vtypes to check number ranges.

It's all working fine, except I need to include my own allowed values ( fie开发者_StackOverflow中文版ld.minValField and field.maxValField) in the 'numberrangeText'. Is there any way to do that ?

Thanks in advance

     Ext.apply(Ext.form.VTypes, {
            numberrange : function(val, field) {
                if(val < field.minValField || val > field.maxValField){
                    console.log(field);
                    return false;
                }
            },
            numberrangeText: 'Value Range Should Be: '

});

Arfeen


There is no way to use templates or XTemplates in numberrangeText. Because they(extjs) just take this string without changes as I've found out from file src/widgets/form/TextField.js from the line errors.push(this.vtypeText || vt[this.vtype +'Text']);.

But as you can see you can use field.vtypeText instead. For example you can write something like this:

field.vtypeText = 'Value Range Should Be: ' + field.minValField + '-' + field.maxValField;

in your numberrange function.

You can see what I'm talking about in this example

0

精彩评论

暂无评论...
验证码 换一张
取 消