Text-field validation

Jan Schenkel janschenkel at yahoo.com
Thu Nov 25 01:18:58 EST 2004


--- Lince m lawrence <lince.lawrence at gmail.com> wrote:
> What should I do the validate a Text-field for only
> numbers (including 
> decimals)? When I used <if theKey is not a number
> then> this returns 
> false for decimals. I need to turn it true.
> 
> I am just a day old with rev (and this is my first
> step with 
> programming). Please help.
> 
> Thanks,
> Lince M Lawrence
> 

Hi Lince,

You can find a simple but effective script in this old
post that I dug up from the archive :
<http://lists.runrev.com/pipermail/use-revolution/2003-September/022446.html>

However, it doesn't handle what comes into the field
through copy+paste or drag-and-drop. You should be
able to fix that with the following additional piece
of script :
--
local sBeforePaste

on pasteKey
  put the text of me into sBeforePaste
  if "checkAfterPaste" is not in the pendingMessages \
  then send "checkAfterPaste" to me in 5 milliseconds
  pass pasteKey
end pasteKey

on dragDrop
  put the text of me into sBeforePaste
  if "checkAfterPaste" is not in the pendingMessages \
  then send "checkAfterPaste" to me in 5 milliseconds
  pass dragDrop
end dragDrop

on checkAfterPaste
  if the text of me is not a number then
    beep
    put sBeforePaste into me
  end if
end checkAfterPaste
--

You may have to tinker a few bits here and there to
make it work for you, but I hope this get you closer
to a solution.

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 


More information about the use-livecode mailing list