If the validation fails, the action handler can choose how to proceed.For “submit” type buttons, that typically means showing error messages next to the relevant form fields.
Use error Class, error Element, wrapper, error Label Container, error Container, show Errors, success, error Placement, highlight, unhighlight, and ignore Title to control how invalid elements and error messages are displayed.does not automatically invoke validators on every form submit.This is actually a good thing, because it makes it much easier to decide when validation makes sense (e.g. We have already seen the most common pattern for invoking validation in our handler for the “order” button: call, but before the possible premature return in case of validation errors.focus Invalid focuses elements when submitting an invalid form.Use the debug option to ease setting up validation rules, it always prevents the default submit, even when script errors occur.This is no problem if the interface exists only for the form, but could be a problem if it is used in other contexts as well.Second, if we want to re-use a validator for multiple forms, we would need to modify multiple schemata.One, remove the "control Box" from the form, so the user cant close it that way. in the btn Cancel_Click event: Removehandeler Text Box1.validating, Addressof Text Box1_Validating -- Terry "Darin" wrote: I know that, but the problem is when the user clicks EXIT, the textbox.validating event is called BEFORE the cancel.click is done, so the textbox is being validated. According to the documentation: "The cancel button for a form is the button control that is clicked whenever the user presses the ESC key." Which says to me the behavior s/b the same! To Short Date String Else Msg Box("Please enter a valid date.") e.Then in the btn Cancel_click event, either set a module level variable like m Canceling to True and then in the validating event ... It doesn't need to be validated because the user is exiting. Length Yes, closing the form causes 'validating' to take place. Close() End Sub Private Sub Text Box1_Validating(By Val sender As Object, By Val e As System. I am going to start a new thread - calling it a bug and see what happens. Down (Down Arrow) and some how (and I never figured this one out) the next control in the tab order, regardless of the Tab Stop property, got focus. Cancel = True End If End If End Sub Hi Al, Nearly 40 years for me since my first college FORTRAN IV class! Well, one of the keys you would not see in either the keypress or keydown events is the tab key, which of course will move the focus.Then in the btn Cancel_click event, either set a module level variable like m Canceling to True and then in the validating event ... I've been fighting the same problem for some time now. I think that the only way to do this is to grab the mouse coordinates in the validating event, do a Window From Point API call, then compare the returned HWND to the Cancel Button's Handle. Close() End Sub Private Sub Text Box1_Validating(By Val sender As Object, By Val e As System. When you click on the button the validating event fires. If the handle matched then immediately exit the Validating event without setting e. -- Al Reid I had tried all of that, *BUT*, I had neglected to set the button's Causes Validation to False. I just don't know what key code combination could direct focus to a text box control that should never receive focus since the Tab Stop property is false and there is no other code that sets focus to the textbox. Also in the docs on Key Down there is a mention of "Is Input Key" which I will have to look into. However, after I removed the "canceling" flag and added the "e.cancel=False" to the form's Form Closing event, I once again see the validation when clicking on the cancel button, but the form then closes after displaying the validation error. -- Al Reid "Terry" Hi Al, Don't know if you have been following the thread I started about the escape key "bug", but if you search this community for "Cancel Button vs Escape Key", you can see the result including the work around for the escape key.When you click on the button the validating event fires. If the handle matched then immediately exit the Validating event without setting e. -- Al Reid Well it works for me - but one thing I left out - you need to set the cancel buttons 'causes validation' to false. Also note that the "trick" to closing the form is not keeping a seperate "canceling" flag, but to put "e.cancel=False" in the forms closing event.