I have a GridView with a textbox in one of its fields. I use a range validator to make sure the user enters only “x” character:
<asp:TextBox ID="txtMP3Master" runat="server" Text='<%# Eval("MP3Master") %>' BorderStyle="None" Width="80%" MaxLength="1" onchange="JSSaveNTSChanges(this);"></asp:TextBox>
<asp:RangeValidator ID="MP3MasterRangeValidator" runat="server" ControlToValidate="txtMP3Master" Display="Dynamic" ErrorMessage="MP3 Master can be nothing but 'x'" Text="*" MinimumValue="x" MaximumValue="x" ValidationGroup="InsertUpdateNewTitlesStatusValidation">
</asp:RangeValidator>
The validator displays “*” on invalid input, but JSSaveNTSChanges() is still called. I want this function call blocked on invalid input. BTW, CompareValidator works correctly in other fields and blocks corresponding functions from being called.
Is it possible to fix this problem?
Thanks.
You should use
CompareValidatorinstead ofRangeValidator.Here is what I have tested on my end. Just try it..