ValidationMask strange behavior

I set a DesktopTextField Validation Mask to 00:00 and I get this instead of 02:12:
image

The longest piece of music ever done !

The documentation says:
# for a number
: time separator

What’s wrong ?

2025r1.1 (but was the same with its predessessor).
Sequoia 15.4.1

Can you provide more information? Like:
Are you typing onto that field?
Are you assigning Text to that Text Field? If so, what are you assigning?
Do you use the Format option on that DesktopTextField?
Care to share some code that you are using on that Text Field?

Edit: if you are using a Validation Mask of 00:00 as 0 is “the literal ‘0’ (zero)”, you should only be able to type 00:00.

I type from the keyboard - no code involved and I changed 0 to # (I was sleepy Emile).

No Text Paste, No Format and yes, it is a DesktopTextField.

I’m sorry, I can’t reproduce here using ##:## as Validation Mask and typing 0212 I get this:

Xojo2025r1.1, macOS 13.7.5


##:## makes my app beep a lot after typing 02
Xojo 2024r4.1 macOS 15.3.2

I can’t test macOS 15.x.x at this moment, tested with Xojo2024r4.1 and macOS 14.7.5 and no problems.

On Windows, I also can’t enter anything unusual.

Then I copied this into Clipboard: 01.01.2020 12:12:12

  • Ctrl-V in the DesktopTextField → does not allow to paste this (expected)
  • Right-Click with Mouse in the DesktopTextField, use Contextual Menu “Paste” → fills it in (unexpected)

On macOS 13.7.5:

  • Ctrl-V in the DesktopTextField → does not allow to paste this (expected)
  • Right-Click with Mouse in the DesktopTextField, use Contextual Menu “Paste” → does not allow to paste this (expected)
  • using a button pressed event with code TextField1.Text = "01.01.2020 12:12:12" → fills it in (expected? -not sure- as assign by code may be expected)

I don’t expect that. 0 isn’t actually the “literal zero”; I use it at various places in formatting strings.
0 has a special meaning: it’s like #, but if there’s no digit at that position, 0 would be shown, as opposed to # which would leave blank (I’m talking about formatting rather than masking here, but remember Xojo uses the same set of characters for both functions).

For instance:

Var d as double=10.5
Var s1 as string=d.ToString(nil,"###.##")
Var s2 as string=d.ToString(nil,"000.00")

s1 shows “10.5” and s2 shows “010.50”.

Looks like you are talking about Format instead of Validation Mask.

From the documentation on Validation Mask:

From the documentation on Format:

image

Edit: didn’t read this part before

Not sure why you are talking about formatting on a ValidationMask thread. And no, Xojo does not use the same set of characters for both functions.

Sorry, I could be wrong. I’m using Format but almost never ValidationMask (and I thought I saw my explanation somewhere, months ago, that would have explained the OP’s attempt).

Just a note that double.ToString uses a similar (but not the same) formatting pattern as Xojo’s Format.

Maybe you know, but maybe others don’t know this. There could be differences if you are using Format for many years and now using ToString:

For example:

var d as Double = -10.5
var s1 as string = Format(d, "###.##")  //10.5
var s2 as string = d.ToString("###.##") //-10.5

and

var d as Double = 10.5
var s1 as string = Format(d, "-###.##")  //10.5
var s2 as string = d.ToString("-###.##") //-10.5

No, it is ValidationMask, set in the IDE:

I Go to DeskopTextField, Then Search for Mask and found ValidationMask (I remember that).

Same result with 2021r2.1

it was Format (API1 to API2)…

Just to be 100% sure (and be back on topic):

  • you can create a new project with just one DesktopTextField, and Duration: label
  • ValidationMask ##:##
  • run
  • you type 0212
  • and you get this:

image

correct?

yes

I hope someone else with Sequoia 15.4.1 can confirm the problem.
We only have this comment so far (with some problem):

but different Xojo and macOS version.

I can’t reproduce with macOS 13.7.5 or 14.7.5

So I tried and got the same result: “0221.10.01 18:”. In fact, as soon as I typed the first “2”, the field changed. I then couldn’t write “12” (because the field was already too long).

Here’s a screenshot demonstrating the behaviour:
ValidationMask.mov.zip (40.8 KB)

1 Like

Try ##:##

I ment ##:## with before the : a backslash \