I'm trying to put some validation in data entry form. I've got the field accepting only numbers and 1 decimal point, however I also need to prevent the user typing in more than 2 digits once the decimal point is in place. Can someone help me with this calculation please?
Ultimately I'm trying to avoid anyone typing in 12345.678
Thanks
Jalz
Code: Select all
on keydown tKey
if tKey is in "1234567890." then
if (tKey is ".") and ("." is in me) then
answer "You cannot have more than 1 decimal in this field"
else
-- if there is a "." and this digit is either 1 or 2 after the "." then
pass keydown
end if
end if
end keydown