There are many ways to skin a cat so the other day I thought I would tidy up some code and put it in a behavior to validate a group of 4 fields.
Since ALL the field were required I added code to make sure they couldn't move to the next field if it was blank.
this is the most basic version below:-
Livecode Version 6.7 and livecode 9 dp6 (to see if it was a consistent bug/undocumented feature)
Code: Select all
on KeyDown pKey
put pKey into the selectedtext
end KeyDown
on EnterInField
ReturnInField
end EnterInField
on ReturnInField
type tab
end ReturnInField
on CloseField
put me && the target
if me is empty then
focus on the target
end if
end CloseField
on ExitField
put me && the target
if me is empty then
focus on the target
end if
end ExitField
I also make enter/return type a TAB character so if they hit return/enter or TAB rather instead of tapping on the next field) it will still go to the next field.
Anyway it didn't work.
Ok it could be because its in a behavior - so I put it in to a group consisting of the 4 fields.
That didn't work either.
Ok try field level - still didn't work.
Try version 9 of livecode - Nope
if I put a breakpoint where i test for empty and single step it works as it should.Curiouser and Curiouser cried Alice
This sounds like I spent 2 minutes testing this but I wasted hours trying to see if there was a way to get this little bit of code (the essence of of the routine) working as it should. - or as usual am i missing something.
There are many ways to solve this - and i've used more than 1 previously but this SHOULD work.
Regards Lagi