TextField Mask

  1. Is there any mask available to input one alphabetic character followed by one numeric? Both are mandatory.
  2. One suggestion: It would be easy to specify something like “9(5)” instead of “99999” (Cobol syntax)

Did you read the documentation on textEdit.mask?

A mask of “A#” would do what want – A is a mandatory alpha character, while # requires a number. There are many other mask values so that you force the input to fit just about anything you’d like.

You can also write your own textEdit subclass to parse the keyboard input if you need more intelligence behind the scenes.

Marc, yes, I read the documentation. “A” is a mandatory alphaNUMERIC mask. This is my problem: “A” doesn’t avoid to enter numerics… So, the solution will be to parse the input…

Yes, in that situation, I’m afraid so. There is the ? operator, which rejects digits, but input for it is optional and you wanted mandatory.

But parsing the entry – making your own masking system – is really easy. Just subclass the control and add in your own logic in the Keydown event and only allow the appropriate characters/numbers through. You can even use RegEx pattern matching for really sophisticated patterns if you want.