Operators are available LessThan, LessThanEqual, NotEqual, Equal, GreaterThan, GreaterThanEqual. You can do the same thing with the type Date, Double, String. In the case of a comparison with a String it will String.Compare method to be used for most crops is in alphabetical order is taken into account.
Validation of a value through an interval of fixed value: Using this time the RangeValidator:
Code:
<Asp: Label runat = "server" AssociatedControlID = "tbCompare2" Text = "Comparison 2" />
<Asp: TextBox ID = "tbCompare2" runat = "server" />
<Asp: RangeValidator runat = "server" ControlToValidate = "tbCompare2" MinimumValue = "01/01/2007" MaximumValue = "31/12/2007" Type = "Date" Text = "*" />
Again we can test dates, integers, floats, and strings, comparisons will be made following today's culture.
Validating a value against another value defined by the user
When you use a CompareValidator with the property ValueToCompare you can replace property ControlToCompare to leave the choice to the user on what value it should look. That's what we use when we want to verify that two passwords are identical.
Code:
<Asp: Label runat = "server" AssociatedControlID = "tbCompare" Text = "Comparison" />
<Asp: TextBox ID = "tbCompare" runat = "server" />
<Asp: TextBox ID = "tbCompare2" runat = "server" />
<Asp: CompareValidator runat = "server" ControlToValidate = "tbCompare" ControlToCompare = "tbCompare2" Operator = "LessThan" Text = "*" Type = "Integer" />
Bookmarks