Validators

  • Thread starter Thread starter Chuck Douglas
  • Start date Start date
C

Chuck Douglas

I am using a CompareValidator to make sure the content in a textbox control
is an integer. I am also using a RangeValidator to make sure the number is
between a certain range.

When the user types an alphanumeric string (i.e. "A67"), both validators
fire. I understand why the CompareValidator fires. Why does the
RangeValidator fire?

In this case, I do not want to see both errors. Is there anyway to have the
second through n validators not get evaluated, if the first validator failed?
Are there other options I should be considering?

Thanks
Chuck
 
Chuck Douglas said:
I am using a CompareValidator to make sure the content in a textbox
control
is an integer. I am also using a RangeValidator to make sure the number
is
between a certain range.

When the user types an alphanumeric string (i.e. "A67"), both validators
fire. I understand why the CompareValidator fires. Why does the
RangeValidator fire?

Both are evaluated on the control, and both fail, so both fire.

BTW, you can set up JavaScript on the control in question that intercepts
the key presses and only allows numbers. This will give you the potential of
not having a compare validator on the control, thus getting rid of the
second message.
In this case, I do not want to see both errors. Is there anyway to have
the
second through n validators not get evaluated, if the first validator
failed?
Are there other options I should be considering?

Other than the above, you also have the ability of creating a custom
validator that watches both conditions.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
Back
Top