Page 1 of 1

quality control fields

Posted: Thu Jul 30, 2009 2:27 pm
by bsouthuk
Hi, i'm working on an application that requires the user to enter digits to answer questions the application asks them.

Basically, the user will click on a button field and a message will appear asking how much something cost. I want it so that if they was to enter a letter by accident then it would not allow it and request the information again.

At the moment my script is

Code: Select all

 ask"How much do you spend on clothes"
then put it into field "clothes"
What code could I add to the script that would not allow anything but digits?

Hope someone can help!

Cheers

Daniel

Posted: Thu Jul 30, 2009 5:06 pm
by !Jerry!
Hi bsouthuk,

you can try this:

Code: Select all

on mouseUp
   ask "How much do you spent on clothes?"
   if it is not a number then
      answer ">" &it&"<  - this is not a number, please enter a new value" 
   else
      -- save the value in variable "it" for next processing
      put it into fld "someField"
   end if   
end mouseUp
regards,
Jerry

Posted: Thu Jul 30, 2009 10:21 pm
by SparkOut
There are various approaches, ranging from the "ask" situation Jerry volunteers, to "keyDown" or "rawKeyDown" handlers in the field to check input. Some examples are, I believe, in the "old" and the "new" RevOnline repositories. (In post Rev 3.5, look for the "Allowed Chars" stack by George C Brackett).
This is quite an old link but no doubt still valid and although it's quite weighty for a "simple" operation like this, is probably the most comprehensive example you'll find: http://www.sonsothunder.com/devres/revo ... fld007.htm

Perhaps a more succinct example is on the site of the late (and sadly missed) Eric Chatonet, http://www.sosmartsoftware.com/?r=revol ... ciels&l=en at #020 How to master users data in entry boxes