How do I limit amount of characters in a field?

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

How do I limit amount of characters in a field?

Post by shawnblc »

Code: Select all

on keyDown theKey
   if theKey is not a number then
      beep
   else
      pass keyDown  -- I'm searching on  a way to limit the amount of characters ex.  limit 5
      end if
end keyDown
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: How do I limit amount of characters in a field?

Post by Dixie »

Hey...

put this in the script of the field...

Code: Select all

on keyDown theKey
   if theKey is not a number then
      beep
      exit keyDown
   end if
   
   if the number of chars of me = 5 then
      beep
      exit keyDown
   else
      put theKey after me
   end if
end keyDown
be well,

Dixie
Post Reply