Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation Event Firing problems

Status
Not open for further replies.

bakershawnm

Programmer
Apr 18, 2007
84
US
Hello all,

Using VS 2008 VB.net 3.5.

I have a form with a set of text boxes with validation events. The first time I use each of the text boxes the validation events fire just fine.

At the beginning of a clear form sub it sets CausedValidation to false on the boxes that have validation so that I can clear them. At the end of that sub it sets CausesValidation back to true. The clear form can be called from a clear button or at the end of the save button.

However when I try to use the text boxes after saving or clearing the form no validation event fires. Why?

Thanks
shawn
 
You shouldn't need to disable the Causes validation.
Do you have a handlers on the text changed event?

You've got questions and source code. We want both!
 
Yes I have text changed event handlers. If I do not disable the causes validation then when I set them to blank it triggers the validation and kicks out an 'Invalid' error.

Until I can figure this out I have moved the validation from Validating/Validated to the TextChanged and commented out the Validated and Validating.

Why should I not have to disable CausesValidation? One of the validation requirements is that the field not be blank. What other way can I set it to blank in the clear function without triggering an 'Invalid' error?
 
1.) Have you stepped through the code and checked to see if the validation code is trying to process?

2.) My comment was on the assumption that you did not have Validation events, but rather text changed events.

3.) Do you really need to run the validation code on every single textChanged event? Normally you can use something like the lose focus event, which gives the user the ability to type text, hold the backspace key down (clearing the box, which would cause an error) and type in the correct value. This will also let you clear the values without running the textChanged event.

I normally put my form validation code in a boolean function and call it in the appropriate button handlers.

Lodlaiden

You've got questions and source code. We want both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top