views:

59

answers:

1

I want to validate a decimal value in an ASP.NET web page using JavaScript, so that the user can enter numbers with only two decimals. The validation should also consider the current UI culture (e.g. ',' instead of '.'). I use Microsoft's Ajax Framework, is there any function included in the library for such a thing?

A: 

If values are separated by spacing you can simply use ^\s*(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)\s*$ regexp (and than use $1 and $2 matches as actual values)

And, more important thing is that all client-side data is insecure by default (because can be forged) so you anyway have to validate it on server.

anonymous