requiredFieldValidater and checking for null values

  • Thread starter Thread starter Andy B
  • Start date Start date
A

Andy B

Is it a good idea to check for null/invalid values even though you have the
requiredFieldValidater doing it for you? or is that a little overboard?
 
Yes, it is a good idea, because it can be easy to forget to check the
IsValid property, and if a hacker for some reason decided to adjust your
code for the validator you would end up with an error. Validators are
intended to make the user interface more friendly for users while filling
out a form, they are not intended to be used as insurance that all values
are valid. However, keep in mind that many form controls (such as TextBox)
will never be null. It may have a Text property of zero length, but it's
still a String. A CheckBox is always True or False, one of the ListItems in
a DropDownList is always selected, etc. Hopefully this helps.
 
Is it a good idea to check for null/invalid values even though you have the
requiredFieldValidater doing it for you? or is that a little overboard?

A RequiredFieldValidator only checks for an empty textbox or undefined
values. It does not check for valid content when it exists.

Other types of validator control can check for coherent content but in
a security critical application you may prefer to carry out further
verification using server-side code. Probably wise.
 
Back
Top