Subclassing WebTextField

Many of my WebTextFields must not be allowed to contain any * or ? in them.
I subclassed WebTextfield and implemented the TextChanged Event as follows:

Sub TextChanged() if InStr(Me.Text, "*") > 0 then Me.Text = Me.Text.ReplaceAll("*", "") if InStr(Me.Text, "?") > 0 then Me.Text = Me.Text.ReplaceAll("?", "") End Sub

I am wondering if this is going to be slow. It obviously doesn’t provide any feedback to the user who may be trying to press either of these characters and they simply just don’t show up.

Any other suggestions on how this can be done simply? (I’ve got a lot of fields that this needs to happen on.)
At the moment when the dialog box’s (which has the WebTextFields) Ok button is pressed these fields are checked and if there is a validation error a dialog box is popped up to inform the user that something hasn’t been entered in correctly.

It seems like the event text changed isn’t called for every key stroke but only after after some idle time or you’ve left the field.

The way I handle this is to have a label on the page/dialog, usually near the Ok/Save button, in red italics or something that stands out. It is normally hidden, and in each field’s LostFocus event I validate the field, and if invalid, set the text of the above label to " can not be blank" or whatever the validation error is, then unhide it. If it is valid, then I hide the label, whether it was previously hidden or not. I also enable/disable the ok/save button accordingly. This performs very well., and the user isn’t interrupted by a message box that they have to dismiss. You can consolidate a lot of this by putting it into a method that you call, passing the control itself.

cool… If you decided that you don’t like the data the user has put in the field and they have tabbed out of the field, how do you send them back to that field? (because you used the LostFocus event, therefore presumably they have changed location.

I forgot to include that I use SetFocus to send them back to the field.