0

I have an HTML Textbox where the user will input data, which in turn will be saved in an SQLcolumn of type decimal(12,4). How will I restrict my textbox to allow either number or decimal value of above-mentioned precision?

This is my textbox code:

@Html.TextBoxFor(m => m.Rate, null, new {@maxlength = "12", style = "width:87px;"})
Arpita Dutta
  • 291
  • 7
  • 19

1 Answers1

0

there is a same question with a proper answer please refer to this link.

link

the answer of this question on the link take only decimal point and if you want number as well with the decimal points.just remove the not sign (!) in this line.

if (charCode != 46 && charCode > 31 
        && (charCode < 48 || charCode > 57))
         return false;
Community
  • 1
  • 1
Durgesh Dangi
  • 215
  • 2
  • 13