2

I have a TextBox that the user need to fill with data a number between 0-90 with 3 decimal places (ex. 0.123 , 1.456 , 1.3 , 45)

i need to validate it.

i can use some validation controls.

  1. RangeValidator with type double, min 0 , max 90
  2. RegularExpressionValidator

what is better?

2
  • 1
    Why couldn't you just use a RangeValidator with the range being .001 to 90? Commented May 31, 2013 at 5:18
  • A regex is tricky as it understands just characters, not values. You probably want to accept "90", but not "90.321". Commented May 31, 2013 at 8:53

2 Answers 2

1

Do it with progressive enhancement in mind.

First make a non-javascript version where the textbox is validated server-side.

Second make a nice javascript validation using a RangeValidator.

Keep the RegEx validator's for phone numbers (1800 Plumbing) , emails, fax's & etc.

Sign up to request clarification or add additional context in comments.

Comments

0

Is this 3 decimal places exactly or it can vary? If it’s 3 exactly I’d go with regex validator because I’m not sure range validator can validate for exact number of decimal places.

Also you need to make sure these are validated on the server side as well.

1 Comment

The validators work both client-side and server-side. Except for CustomValidator, where you have to write both sides yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.