user2179026
user2179026

Reputation:

Range validation not working

We have written as below lines of code

<div class="controls">
<asp:TextBox ID="txtPort" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator   CausesValidation="true"    ID="rfvprot"     runat="server" ErrorMessage="Enter port number." ControlToValidate ="txtPort">*</asp:RequiredFieldValidator>
 <asp:RangeValidator   CausesValidation="true"    ID="RVPort" runat="server" ErrorMessage="Enter value between 1 to 65000" ControlToValidate ="txtPort" MinimumValue ="1" MaximumValue ="65000"></asp:RangeValidator>
</div>

If we enter value 667 or any value, then click on submit button, it still displays the validation message.

Upvotes: 1

Views: 908

Answers (3)

ilyabreev
ilyabreev

Reputation: 634

Try to add CausesValidation="true" to your submit button.

Upvotes: 2

brtb
brtb

Reputation: 2311

have you tried add Type="Integer" attribute to range validator

Upvotes: 3

Conrad Lotz
Conrad Lotz

Reputation: 8818

You can try and add a type to the RangeValidator

 <asp:RangeValidator Type="Double"  OR
 <asp:RangeValidator Type="Integer"  

Upvotes: 0

Related Questions