I have a asp.net Textbox control which is tagged to accept amount values. It should not accept any value more than 3 decimal places.

123.1 - True

123.12 - True

123.123- True

123.1234 or 12.1234 - False

```
<asp:TextBox ID="Amount" runat="server" Width="500px" Visible="false" onkeypress="return isNumber(this,event)"/>

```

Javascript code below.

> 
> 
> ```
> <script type="text/javascript">
> 
>         function isNumber(txt, evt) {
>             var charCode = (evt.which) ? evt.which : evt.keyCode;
> 
>             if (charCode == 46) {
>                 //Check if the text already contains the . character
>                 if (txt.value.indexOf('.') === -1) {
>                     return true;
>                 }
>                 else {
>                     return false;
>                 }
>             }
>             else {
>                 if (charCode > 31
>              && (charCode < 48 || charCode > 57))
> 
>                     return false;
>             }
> 
>             return true;
> 
>         }
>  </script>
> 
> ```
> 
> 

The JS will validate numerics and .(dot) to be only once. I've tried various combinations of regex which fails. Needs a regex to be handled in JS functions appropriately.
Among the various regex I've applied, here are few "\d+(.\d{1,3})?$", "/^\d+(.\d{1,3})?$/"...