General information
Category:
Coding, syntax & commands
>To All:
>Please recommend ways of checking a TextBox to see if it is empty or also that it contains only Alpha characters. The code should then post a MessageBox telling the operator that the field cannot be blank or some character is invalid. Then the cursor should return to the same field to allow correction of the problem. I tried using the Valid event but it pops a nasty little wait window that I would rather not see. I will use this code to check each Textbox on the form.
Eric;
Another thought: Required fields can use a highlighted background, as a visual aid to users. Additionally, there are a number of ways to do validations, depending upon requirements and design. Validation at the object level as you described can be a time saver to the user as opposed to putting validation code in only the Save method.
There is nothing a user hates more than "completing data entry into a form" and attempting to save his/her work, only to be told upon hitting the Save Button, "Hay Charlie, you forgot something - fill in the required data". After receiving a few such messages users get upset! However, the Save method will still have to check for your business rules. So you may end up with code in both places.
Creating a textbox class with the required methods supporting what you want to do is a good way to go. It would take care of the Alpha character Formatting, background color (if you wish to use this visual aid) and code. My first framework incorporated textboxes for numeric, alpha, date, zip code, and telephone number formatting, to name a few.
Tom
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only