Page 1 of 1

Quick Code Question

Posted: Mon Mar 02, 2026 4:46 am
by isabellspivey
Hello,
How can I stop the application from proceeding until a field contains a minimum number of characters? I’m at the end of a kiosk workflow where patients swipe their cards, and I need the script to remain idle until the required data has been entered.

Re: Quick Code Question

Posted: Mon Mar 02, 2026 7:55 am
by Emily-Elizabeth

Code: Select all

on KeyUp
   CharCheck
   pass KeyUp
end KeyUp

on DeleteKey
   CharCheck
   pass DeleteKey
end DeleteKey

on BackspaceKey
   CharCheck
   pass BackspaceKey
end BackspaceKey

private command CharCheck
   set the enabled of button "OK" to (the number of characters of me >= 3)
end CharCheck

Re: Quick Code Question

Posted: Fri Apr 24, 2026 10:59 am
by charleshallock
Hello, don’t try to “pause” LiveCode—it will freeze the UI. Instead, validate and only proceed when the field is long enough.

Simplest approach:

Code: Select all

on returnInField
   if the number of chars of me < 6 then
      answer "Enter at least 6 characters."
      exit returnInField
   end if
   go to card "NextScreen"
end returnInField
Or validate while typing:

Code: Select all

on keyUp
   if the number of chars of me >= 6 then
      go to card "NextScreen"
   end if
end keyUp
Don’t block execution—control when you advance.

Re: Quick Code Question

Posted: Fri Apr 24, 2026 2:53 pm
by dunbarx
Many ways to do this, as you have already seen. I like, in the script of the offending field:

Code: Select all

on textchanged
   if the length of me >= 6 then doYourThing
end textchanged
Craig