I have a form with several text fields on it. I just want to accept floats, but most likely users will enter a dollar sign. I use the following code to remove dollar signs and check the contents:
JQuery
$("#<%= tb.ClientID %>").change(function() { var ctrl = $("#<%= tb.ClientID %>"); ctrl.val(ctrl.val().replace('$','')) });
Checking asp.net:
<asp:CompareValidator ID="CompareValidator4" runat="server" Type="Double" ControlToValidate="tb" Operator="DataTypeCheck" ValidationGroup="vld_Page" ErrorMessage="Some error" />
My problem is that when someone enters the dollar sign into the TextBox "tb" and the changes are focused, the check is done first, and THEN jQuery removes the dollar sign. Is it possible to start jQuery first or force a validation after jQuery?
source share