Page 1 of 1

how to check field format during entry

Posted: Sat Apr 10, 2010 8:51 pm
by fmuller
Hello,

I search if something exist to check what is entered inside a field on screen like a format template.
For some fields I would like just numbers, others just characters and so ...
Some languages have input values like "####" means only 4 numbers or "##/##/####" means a date.

Thanks for help,
Cheers, Fabrice

Re: how to check field format during entry

Posted: Sun Apr 11, 2010 4:36 pm
by Klaus
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

Re: how to check field format during entry

Posted: Sun Apr 11, 2010 8:55 pm
by fmuller
Hi Klaus,

Alles gut und dich, hast du ein schönes Wochenende gehabt ?

I switch to English, it's easier :-) Thanks a lot for your solution I will try it.

Cheers from Switzerland, Fabrice

Re: how to check field format during entry

Posted: Sat Dec 14, 2013 1:35 pm
by FLCo
FieldFormatter is now available...

http://www.FlexibleLearning.com/fieldformatter

It does exactly what you are asking for.

Hugh Senior