I want to validate a decimal value in an ASP.NET we开发者_Python百科b 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?
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.
精彩评论