Вопрос

however my question is simple but I don't know it's answer. I use range validators in my project. I know how they work for integer or float or dates but I don't know how they works for strings. for example if the min value is "xx" and the max value is "zzyyyz" ,what the users can enter? can you get me an example?

Это было полезно?

Решение

If you look at the documentation of the RangeValidator, it appears you can specify a string type:

<asp:RangeValidator runat="server"
                    MaximumValue="zz"
                    MinimumValue="xx" 
                    Type="String" 
                    ... />

Although you may be better off using a RegularExpressionValidator. In this example, you'd have:

<asp:RegularExpressionValidator runat="server"
                                ValidationExpression="^[x-z]{2}$"
                                ... />
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top