thevan
thevan

Reputation: 10344

How to validate a ASP.Net TextBox which should allow negative or positive decimal value with three decimal places?

I have a textbox which should allow user to enter only positive or negative decimal number with three decimal places. For Example: 73.345 or -2345.345 or -32.34. something like that. How to set the validation for this?

Whether validation is by either using Validation Controls or by JavaScript. Any suggestions please.

Upvotes: 0

Views: 1920

Answers (1)

DocMax
DocMax

Reputation: 12164

I would use a RegularExpressionValidator to do the work for you. Your regular expression, assuming the decimal point and digits immediately following are options, is then:

-?\d+(\.\d{1,3})?

Upvotes: 4

Related Questions