Reputation: 2632
This my asp:RegularExpressionValidator
<asp:RegularExpressionValidator ID="RegularExpressionValidator2"
runat="server" ControlToValidate="uxTrachoCtrl1"
ErrorMessage="Ne dois pas contenir des caractères alphabétiques"
ValidationExpression="[0123456789,.<>=]" ValidationGroup="verification" Display="Dynamic"
SetFocusOnError="True">
</asp:RegularExpressionValidator>
The string can contain only those characters 0123456789,.<>=
This my regex [0123456789,.<,>,=]
It works if I type one character like f or 1, but if I put more than one character this will raise an error:
ex: input="1"=ok
input="f"=error
input="11"=error (It's supposed to be right)
Upvotes: 0
Views: 420
Reputation: 8415
you just have defined the range of valid characters for one character
change it to
ValidationExpression="[0-9,.<>=]{minLength,maxlength}"
instead of minLength
and maxLength
you should put your desired numbers .
or use *|+
if you want to allow 0|1
or more repeat of characters as others suggested
Upvotes: 0
Reputation: 44259
The character class matches only one character. You need to repeat it if you want to allow arbitrary length characters:
"[0-9,.<>=]*"
If you want to exclude empty inputs use this instead:
"[0-9,.<>=]+"
Note that my character class is equivalent to yours (0-9
is a shorthand notation for 0123456789
and you had the ,
multiple times in your character class).
Upvotes: 6