sarah.reichelt at gmail.com
Sun Sep 10 15:41:03 CDT 2006
On 9/11/06, Trevor Hopkins <tjhopkins224 at hotmail.com> wrote:
> I'm trying to build a form whose "submit" button only becomes enabled after
> text is present in a specific field (and likewise when that field is blank,
> the "submit" button returns to disabled status). Does anyone know of a
> painless way to do this? I'd also like the user to be able to hit return
> from within that field and have the "submit" button entered. Right now, it
> seems, the return key must be hit twice in order to first exit the field and
> then select "submit".
I like to use a "send in time" message that checks all the relevant
fields and enables or disables buttons accordingly. I prefer it to
closeField as it happens in real time, instead of waiting for the user
to get out of the field.
-- start the messsage going
send "checkButtons" to me
-- check all the things you need & set the button
-- you can make this check as complex as you like
if fld "Essential" is empty or fld "Number" is not a number then
disable btn "Submit"
enable btn "Submit"
-- send the message again
if the pendingMessages contains "checkButtons" is false then
send "checkButtons" to me in 10 ticks
-- stop the message when closing the card
put the pendingMessages into tList
repeat for each line L in tList
if item 3 of L contains "checkButtons" then cancel item 1 of L
Then for the Return key being able to hit the button:
click at the loc of btn "Submit"
I like this method as it won't do anything if the button is disabled,
and if it does work, it gives visual feedback of the buttoon being
Don't forget that you can also use enterInField and if the autoTab is
set to true, you might like to use the tabKey message.
More information about the use-livecode