Validation of data in custom dialog to accept only one single number - script
I have an input system in FMP11 that uses a dialog box with a global field to input quantities for each record. On click OK the script will add the value in the record proper field.
The users should enter just one number in that dialog box global field (e.g.: "10" or "-10").
I'm trying to create a validation script to make sure that the users don't type weird stuff except that one number.
(It happened that they typed expressions and spaces, making the system fail. e.g.: "+10-5+ 30- 15" ).
So far I got to his:
Once typed the value in the Custom dialog GLOBALFIELD and click OK ->
If [(Lenght ( Filter ( Lower ( GLOBALFIELD ) ; "1234567890-" ) )) = ( Lenght ( GLOBALFIELD) )) ) and ( Patterncount ( GLOBALFIELD ; "-" ) ≤ 1 )]
Set Field ( RECORDFIELD ; RECORDFIELD + GLOBALFIELD)
Error message and Exit Script
On my tests everything looks fine but I would appreciate any comment from an external eye.
Thank you all for your help.
Have a great day.