checking text field is less than a number

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
ady.bolton@me.com
Posts: 2
Joined: Thu Nov 29, 2012 10:01 pm

checking text field is less than a number

Post by ady.bolton@me.com » Thu Nov 29, 2012 10:07 pm

I'd like to check the number entered into a text field is less than 32 on loosing focus of the field.

I've tested the below code with <> and it pops my message up correctly. I can't get < to work though and I've tried everything. I can't believe I've spent 2 hours on this!

on closeField -- make sure the user has entered a valid date
put field "dinm" into dm
if dm < 32 then
beep
answer "Maximum Days in Month is 31."
select text of me
end if
end closeField

ady.bolton@me.com
Posts: 2
Joined: Thu Nov 29, 2012 10:01 pm

Re: checking text field is less than a number

Post by ady.bolton@me.com » Thu Nov 29, 2012 10:17 pm

Sorry, think I'm just tired. Fixed it now without doing much different:

on closeField -- make sure the user has entered a valid date
put field "dinm" into dm
if dm > 31 then
beep
answer "Maximum Days in Month is 31."
select text of me
end if
end closeField

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

Re: checking text field is less than a number

Post by dunbarx » Thu Nov 29, 2012 11:28 pm

Ah, the best way to learn. Sweat.

But "...without doing much different"?

Although little was changed in terms of typing, the two scripts are not at all the same in functionality. The first one was one of those forehead slappers.

Sometimes the sweat comes from simple logical or mental lapses, rather than code, syntax and vocabulary struggles. Good work. Keep at it.

Craig Newman

Post Reply