在asp.net范围验证器不能按预期工作 [英] Range validator in asp.net doesn't work as expected
问题描述
我有这种房车在我的网页文本框:
I have this RV for a textbox in my page :
<asp:RangeValidator ID="titleRV" runat="server" ControlToValidate="titletxt" Font-Bold="True" Font-Size="Small" ForeColor="Red" MinimumValue="4" MaximumValue="100" Type="Integer" SetFocusOnError="True" Display="Dynamic" >Must be more than 3 !</asp:RangeValidator>
当我在文本框在运行时输入任何字符范围验证看来我是否输入少于3个字母或没有,如果我增加的字母数不会消失!任何帮助吗?
when I type any number of characters in my textbox at runtime the range validator appears whether I typed less than 3 letters or not ,and if I increased the number of letters it doesn't disappear! any help please ?
推荐答案
一个范围验证的目的是检查是否在范围内输入一个值 - 例如一个数字0到100之间,并像你这听起来我尝试检查是如何进入的信函呢?
A range validator is designed to check that you enter a value in a range - for example a number between 0 and 100. It sounds to me like you're trying to check how many letters were entered?
假如我正确地理解我的建议是使用正则表达式验证器。
Assuming I've understood correctly my suggestion would be to use a RegEx validator.
您可以使用一个前pression这样的:
You could use an expression like:
<asp:RegularExpressionValidator ID="valLength" runat="server"
ErrorMessage="Your text must be between 3 and 100 characters"
ValidationExpression="^[0-9a-zA-Z]{3,}$"
ControlToValidate="txtTextBox" />
这显然取决于你允许
这篇关于在asp.net范围验证器不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!