Numbers or text only in a field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 56
- Joined: Sat Jun 20, 2009 2:41 pm
Numbers or text only in a field?
Is there a simple way to only let a user enter numbers into a text box? (or letters only for that matter?)
In another language I remember where you could mask or set a field to only accept one or the other. Is there something like that in RunRev?
In another language I remember where you could mask or set a field to only accept one or the other. Is there something like that in RunRev?
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
If you put this in the script of your field:
The user will be restricted to entering only the characters listed.
Of course it gets more complex if you want to avoid a leading decimal point, or multiple decimal points, but you get the idea.
Best,
Mark Smith
Code: Select all
on keyDown pKey
if pKey is in "0123456789." then pass keydown
end keyDown
Of course it gets more complex if you want to avoid a leading decimal point, or multiple decimal points, but you get the idea.
Best,
Mark Smith
Ok boys I am new but here is a script which has evolved into one of my fields.
This may not be perfect but it works.
Code: Select all
on keyDown theKey
if the length of the selectedText of me > 0 and thekey is a number then pass keyDown
else if thekey is "." and offset(".",me) = 0 then pass keydown
else if theKey is not a number or the length of me >= 5 then focus me
else pass keyDown
end keyDown
on exitfield
put format("%05.2f",me) into newvar
put newvar into me
end exitfield
on closefield
put format("%05.2f",me) into newvar
put newvar into me
end closefield
Developing with Windows XP & Revolution 4.5
-
- Posts: 56
- Joined: Sat Jun 20, 2009 2:41 pm