How can I reject letters in a field that can have numbers, "." and "/", but no letters?
Thanks,
David
How can I reject letters in a field for number? - Solved
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How can I reject letters in a field for number? - Solved
Last edited by DR White on Sat Mar 24, 2018 12:34 pm, edited 1 time in total.
Re: How can I reject letters in a field for number?
Hi David,
This should work
Best regards
Jean-Marc
This should work
Code: Select all
on keydown pKey
put "1234567890./" into tMyAllows
if pKey is in tMyAllows then
pass keydown
end if
end keydown
Jean-Marc
https://alternatic.ch
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: How can I reject letters in a field for number?
One EXTREMELY CLUNKY, STEAM-DRIVEN SOLUTION coming up:
{blaming it on my 101 degree temperature
]
And there's Monsieur Burnod "pipping me at the post"
Code: Select all
on mouseUp
put empty into fld "f2"
put fld "f1" into FFF
put 1 into KOUNT
repeat until char 1 of FFF is empty
if (char 1 of FFF = "1") or (char 1 of FFF = "2") or (char 1 of FFF = "3") or (char 1 of FFF = "4") or (char 1 of FFF = "5") or (char 1 of FFF = "6") or (char 1 of FFF = "7") or (char 1 of FFF = "8") or (char 1 of FFF = "9") or (char 1 of FFF = "0") or (char 1 of FFF = ".") or (char 1 of FFF = "/") then
put char 1 of FFF after fld "f2"
end if
delete char 1 of FFF
add 1 to KOUNT
end repeat
end mouseUp

And there's Monsieur Burnod "pipping me at the post"

Re: How can I reject letters in a field for number?
Jean-Marc,
WOW. That is so much cleaner then what I was trying to do and it works well.
Thanks So very much,
David
----------------
richmond62,
We program very similar, "STEAM-DRIVEN" style. It gets the job done,
but not in the cleanest and easiest way.
Thanks for your suggestion,
David
WOW. That is so much cleaner then what I was trying to do and it works well.
Thanks So very much,
David
----------------
richmond62,
We program very similar, "STEAM-DRIVEN" style. It gets the job done,
but not in the cleanest and easiest way.
Thanks for your suggestion,
David
Re: How can I reject letters in a field for number? - Solved
Before Colin Holgate pipes in, since he is notorious for reducing handlers to the fewest possible lines, Jean-Marc's excellent solution could be:
I only mention this so that the workings of the keyDown message are fully understood, that if the message is not passed, no text is forthComing.
Craig Newman
Code: Select all
on keydown tKey
if tKey is in "0123456789./" then pass keyDown
end keydown
Craig Newman