Limit Textbox inputs to Format
From: Brian Stigler (bkstigler_at_usa.net)
Date: Tue, 17 Feb 2004 18:20:53 -0800
Here's an interesting one... I haven't had any luck coming up with a slick
I have a set of textboxes on a form. Each of the textboxes has an
associated format string for numeric input.
The associated formats can be different from run to run so I can't hard code
a format to a particular textbox... I just read the format string from an
XML input file.
Here's my question:
I would like to limit the user to numeric inputs only.... (no characters)
and also limit them to numbers in the format specified for each textbox.
So for example... if a user inputs 2a, the system would beep and the textbox
background would maybe flash red for a brief second indicating that the
input is invalid. Also, the character "a" would not be displayed since it
is an invalid character. (This eliminates the option of using the LostFocus
event since I would like an immediate response to the user.)
For valid numeric inputs... the user could input 1.23 and no more for a
textbox with a format of "0.00". Trying to type "1.234" would again yield a
beep and a red flash and the "4" would not be displayed since it exceeds the
Thanks a bunch as always.