TextField mask with an optional number?

If I have a mask of 9#.999, I can not enter just 1.5. When I press 1. I get a beep. I can enter 01 and then the period is inserted automatically and I can then type 5.

How can I allow for entry of 1 or 2 digits, then a period, then up to 3 optional digits?

Not an expert, but have a suggestion to you. Do a if …else with two different masks. Read the Len before that.

The mask is set in the GUI designer. My understanding was that 9 is an optional number, # is a required number and . is a literal period. I do not see why multiple masks are required?

Is this a bug then? I’ll create a case, I am just not sure if I am using it wrong or not.

Try “#9.999” :slight_smile:

If you use 9#.999, the first digit you enter maches the leftmost 9. Then Xojo expects as next input a required number ("#") - so you can not just enter “.”

But if you use “#9.999”, the first input matches the “#”, then the second digit can be omitted and the “.” can be entered.

[quote=14397:@Jürgen Kurowski]Try “#9.999” :slight_smile:

If you use 9#.999, the first digit you enter maches the leftmost 9. Then Xojo expects as next input a required number ("#") - so you can not just enter “.”

But if you use “#9.999”, the first input matches the “#”, then the second digit can be omitted and the “.” can be entered.[/quote]

That indeed did the trick. Didn’t think about how it all matched but your explanation makes it clear, thanks!