Notifications
Clear all
[Closed] EditText Filter
Aug 07, 2009 5:38 pm
I was wondering if it is possible to add a filter to an EditText?
I would like to use it only for integers.
I tried this:
Fn IntegerFilterFn txt = iskingof txt integer
Edittext edtInt "" filter:IntegerFilterFn
2 Replies
Aug 07, 2009 5:38 pm
Not directly. What I have done in the past is to run a test on each entry using the on changed event. I take the string that is entered and parse it for only the items that are allow and add it back to the field.
fn filterForNumeric str=
(
outStr=""
if classOf str==string do
(
numbers=#("1","2","3","4","5","6","7","8","9","0")
for i = 1 to str.count do
(
if (findItem numbers str[i])!=0 do outStr+=str[i]
)
)
outStr
)
filterForNumeric "a23JSh:K&^876"