locked
RangeValidator.MaximumValue = Double.MaxValue.ToString() fails! RRS feed

  • Question

  • User2108273466 posted
    Hello!

    I'm trying to set the MaximumValue of a RangeValidator to Double.MaxValue. That fails.
    I found an article that explains that RangeValidator uses a RegularExpression to validate this value. See this post:

    http://stup.org/blogs/nidhogg/archive/2004/12/15/410.aspx

    Does someone know how I could set a such value in my validator (or another very large value). I Tryed Int64.MaxValue and it seems that don't works.

    Tank you for you answers!

    David.

    Friday, July 28, 2006 3:19 AM

All replies

  • User2108273466 posted
    After verification, Int64.MaxValue works... But this is not the same than a Double value. If someone know the solution, let me know ;-)
    Friday, July 28, 2006 4:17 AM
  • User1806792307 posted

    Hello!

    I found an article that explains that RangeValidator uses a RegularExpression to validate this value.

    I want to clarify something. RangeValidator does not use a regularexpression to validate a double. It uses a regular expression to extract the digits and decimal character out of the string. It then converts the result into an actual number using the javascript parseFloat() function. If that function cannot convert, the RangeValidator knows the value was not acceptable to javascript.

    I suspect that the problem is that the value you are assigning to MaximumValue is too large for javascript's floating point. I think both .net's Double and javascript are 80bit floating point but its possible they are slightly different at the min and max range. In any case, I recommend changing your code like this:

    - Use a CompareValidator, Operator=DataTypeCheck, Type=Double. It will report an illegal value due to the format or its too big for an 80 bit number.

    - Use another CompareValidator, Operator=GreaterThanEqual, Type=Double, ValueToCompare= your minimum double. This will report an error if anything is below the minimum. The max was handled in the other validator.

    Friday, July 28, 2006 12:35 PM