Hi,
I have a window with 5 TextFields in a TextField Set (see below):
TextField1(0)
TextField1(1)
TextField1(2)
TextField1(3)
TextField1(4)
I need to ensure that TextField1(0) can only accept numbers - without affecting any of the other TextFields in the set.
If I use a KeyDown event handler, it works on ALL of the TextFields, and not just TextField1(0).
Any ideas how I can make it only work for TextField1(0).
I am thinking maybe :
if index = 0 then
But I am not at my computer at the moment, so cannot try it out.
Thank you all in advance.
In your keydown handler:
If index = 0 Then
//add a mask to only allow numbers
else
//add code for how the other members of the control set should behave.
end if
I thought so, just wanted to check.
Thank you very much
Another thing to consider is that, if you consistently want different behavior for TextField1(0) than the other fields, maybe it doesn’t belong in the control set but rather as a separate control
I agree, but my app got bigger and bigger and bigger, and before I knew it, it was too late and too complex to change. lol
Thank you all.
DaveS
(DaveS)
February 19, 2014, 6:31pm
6
In the future you might want to consider creating a custom TextField subclass. This would contain an attribute indicating what type of data the user is allowed to enter.
I have one I created that allows
plain text
forced upper case
currency (US)
Date
Date/Time
Time
valid email address
Integer Numbers
Floating Point
Password
Phone # (US)