使用一个范围验证器,我可以检查不同的范围吗? [英] using one range validator, can I check different ranges?

查看:84
本文介绍了使用一个范围验证器,我可以检查不同的范围吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我想检查文本框中的用户输入应该在1到100之间,是否可以仅使用一个范围验证器来检查?如果是,如何设置最小值和最大值? ="h2_lin">解决方案

实际上听起来您想使用正则表达式验证器来处理此问题.范围验证器需要与最小值和最大值相关联的类型.即使从理论上讲,您可以提供一个用逗号分隔的最小值和最大值列表(您不能这样做),但它们必须具有相同的类型才能起作用.在编译期间,验证器将检查您在最小值和最大值中指定的值是否可以转换为您提供的类型.

正则表达式验证器可以轻松检查1-100之间的数字范围和/或a-m之间的字符.


say I want to check that user inputs within a text box should be within 1-100 and a-m, can I use only one range validator to check that?if yes ,how to set the minimum and maximum values?

解决方案

It actually sounds like you would want to use a regular expression validator to handle this. The range validator expects a type asssociated with the min and max values. Even if theoretically you could provide a comma separated list of min and max values (which you can''t), they would have to be of the same type in order to work. During compile, the validator will check that the values you specified in the min and max values can be converted to the type that you supplied.

A regular expression validator could easily check for a numeric range from 1-100 and/or characters between a-m.


这篇关于使用一个范围验证器,我可以检查不同的范围吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆