Ensuring numeric input
FlexibleLearning at aol.com
FlexibleLearning at aol.com
Fri Oct 28 04:18:19 EDT 2005
Ooops. Late again. My standard numberField solution is similar to Michael's
but simpler as it doesn't need to handle multiple lines. It does, hoever,
validate pre- rather than post-process and restores the old value if necessary...
local lOldValue
on openField
put me into lOldValue
end openField
on keyDown tKey
if (tKey=".") AND ("." is in me) then exit keyDown
else if (tKey="-") AND (me="") then pass keyDown
else if tKey is in "0123456789." then pass keyDown
end keyDown
on closeField
set the numberFormat to "0.00"
put line 1 of me into me
if me is NOT a number then put lOldValue into me
else add 0 to me
end closeField
/H
FLCo
Home of the Scripter's Scrapbook
www.FlexibleLearning.com/ssbk.htm
More information about the use-livecode
mailing list