Quick Code Question

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!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
isabellspivey
Posts: 5
Joined: Mon Aug 18, 2025 3:20 am

Quick Code Question

Post by isabellspivey » Mon Mar 02, 2026 4:46 am

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.

Emily-Elizabeth
Posts: 195
Joined: Mon Jan 03, 2022 7:10 pm
Contact:

Re: Quick Code Question

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

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

charleshallock
Posts: 5
Joined: Tue Jul 15, 2025 7:50 am

Re: Quick Code Question

Post by charleshallock » Fri Apr 24, 2026 10:59 am

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10490
Joined: Wed May 06, 2009 2:28 pm

Re: Quick Code Question

Post by dunbarx » Fri Apr 24, 2026 2:53 pm

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

Post Reply