Use the method
System.Decimal.TryParse
; if it returns true, the string is valid as a decimal representation:
http://msdn.microsoft.com/en-us/library/system.decimal.tryparse.aspx[
^].
After that, take parsed value and additionally check up for required range or any other constraint.
[EDIT]
OK, for client side, this is a JavaScript variant. Checking up if the numeric value is valid is more tricky:
function isValidFloat(stringValue) {
value = parseFloat(stringValue);
return (value == value);
}
Note: there is not "decimal", only floats and integers.
When this is done, check for your constraints the same way.
—SA