Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
I have found lots of help on what I need but all seem to want me to use pKey. if pKey is not a number then ...
I think this will not work for me because I have buttons that auto fill fields with text. Maybe I'm wrong.
What I would like is to check the field AFTER data entry for letters.
if fld "field 1" contains "a-z" then
answer "no letters allowed"
is this doable?
Thank you in advance and you are all awesome
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Why not loop through all the chars in the field and eliminate those that are in "abcd...z"? Case would not matter, which is a benefit. And "repeat for each..." is really, really fast. Write back if you get stuck, but this should be fun.
Craig Newman
Edit, upon rereading, I see what you really asked for. Now you would loop through all 26 chars, and stop if even one of them was in the source text. Faster yet, the size of the source now being irrelevant. The first post would be a way to delete the offending chars.
-- in card's script (for all fields on card)
-- or in field's script (for that field only)
on closeField
if matchtext(text of the target,"[a-zA-Z]") then
answer "No letters (a-z or A-Z) allowed."
select text of the target
else pass closeField
end closeField
The best solution is: ########CODE####### on keyDown pKey if pKey isnotanumberand pKey isnot"."then beep else pass keyDown endif end keyDown #####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Depends upon what he wants.
For example space, minus, plus, parentheses, brackets are also allowed with phone numbers.
Or: Numbers and "." are *not* the complement of a-z & A-Z
[-hh] wrote:Depends upon what he wants.
For example space, minus, plus, parentheses, brackets are also allowed with phone numbers.
Or: Numbers and "." are *not* the complement of a-z & A-Z
If you need more, just add it: ########CODE####### on keyDown pKey if pKey isnotanumberand pKey isnotin"+-.,()[]{}"then beep else pass keyDown endif end keyDown #####END OF CODE#####
However you solution is better with autofill button.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
The OP wanted to validate AFTER the field had been populated. That is, all at once at some later time. Any solution that uses "keydown" is validating on the fly.
@MaxV.
It's often advantageous to consider what is simpler to enumerate, a set or its complement.
May be you are right. But just to keep you busy with beeping:
Now assume he wants to have some words containing *only* a-z or A-Z to be typed (for example for a userName).
-- in card's script (for all fields on card)
-- or in field's script (for that field only)
on closeField
if matchtext(text of the target,"[a-zA-Z]") then
answer "No letters (a-z or A-Z) allowed."
select text of the target
else pass closeField
end closeField
That did it, almost, Had to Add a break after select text of.. and i had to change the target to fld "welder" then it worked perfect, thank you all for your help.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
The "break" command is only for use in switch statements. If it works here, it's by accident and I wouldn't rely on it. You shouldn't need it anyway, the "if" clause should handle everything by itself.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
I found that If using the mouse to click into another field, it will give the message about no letters, but it will still move to the clicked on field leaving the field with illegal characters
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här