Is there a way to only allow numerics to be entered in a field.
ie. if the user tries to enter a non numeric, the character is ignored.
Warren
Only allow numerics
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
The (v. 3 at least) Resource Centre has some info about this.
Under "Sample Scripts" > "Text" there is a section "Accepting only digit characters during data entry" which suggests is a good place from which to start.
You could leave out the beep obviously. In order to catch non-alphanumeric keystrokes, like backspace and delete you will need to use a variation, which handles the rawKeyDown message, and check for the character number relating to the keys you need to test, such as backspace.
Under "Sample Scripts" > "Text" there is a section "Accepting only digit characters during data entry" which suggests
Code: Select all
on keyDown theKey
if theKey is not a number then beep
else pass keyDown
end keyDown
You could leave out the beep obviously. In order to catch non-alphanumeric keystrokes, like backspace and delete you will need to use a variation, which handles the rawKeyDown message, and check for the character number relating to the keys you need to test, such as backspace.