-2

i have to check a textbox control for validation

Conditions:

  1. contain value 0 to 1000 upto 2 decimal places( 1.00,85.23,1000.00)

  2. after 2 decimal points user wont be able to enter any more zeros.

    <script type="text/javascript">
    
    var regex = /\d{0,4}([\.])\d{0,2}/;
    function keyUP()
    {   
          var t = document.getElementById('<%=TextBoxPayRate.ClientID%>').value;
          if (!regex.test(t)) 
          {
             alert("not matching");
          }
    }
    </script>
    
    <asp:TextBox ID="TextBoxPayRate" runat="server"  onkeyup="keyUP();"></asp:TextBox>
    
huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
Aman
  • 224
  • 2
  • 4
  • 14

1 Answers1

0

Hi you should be able to use/modify the updated code on this post to acheive what you require.

Remove "$" before ASP.Net RangeValidator script executes

Community
  • 1
  • 1
Luke Baughan
  • 4,658
  • 3
  • 31
  • 54