Grüezi Fabrice,
ca va bein?
fmuller wrote:...For some fields I would like just numbers, others just characters and so ...
This is quite straighforward!
Put this into the fields script to allow only numbers as input including prefix -+ and decimal delimiter which is comma in my example!
Code: Select all
## We check the typed character BEFORE we put them into the field!
on keydown tKEy
if tKey is in "1234567890,-+" then
## Typed character OK, let it pass
pass keydown
end if
end keydown
Same for non numeric input:
... if tKey is in "abcdefghijklmnopq..." ### etc...
Hint: "A = a" if you do not "set the wholematches to true" before you compare something!
fmuller wrote:Some languages have input values like "####" means only 4 numbers or "##/##/####" means a date.
THis is not built in into Rev unfortunately.
But you can check the field after the input and format the content accordingly.
Use the "closefield" handler to do so and maybe the "format" function.
Example: User entered a number (1) but we woul like to see the field formatted like 1.00:
Hint: the engine always uses english decimal formatting 1.00, so here in my scripts in germany I do:
...
replace "." with "," in tnumber
...
Before I put the string back into the field.
Code: Select all
on closefield
put me into tnumber
put format("%1.2f",tnumber) into me
end closefield
Of course there is a lot of errochecking needed, like empty fields etc...
Hope that helsps!
Best from germany
Klaus