Input Mask for Text boxes

torg

Regular
Joined
Nov 7, 2002
Messages
60
Location
Norway
I have ta textbox "txtInput " I would Like to hav an input mask alias "DD.MM.YYYY". How can I achieve this ?
 
I still want a MaskEdit :)
I also want to be able to make an phonenumber input like this:
"555-12345645". :)
 
By DD-MM-YYYY are you assuming numbers for each place? A mask like ##-##-####...? You can't really mask the date values specifically (to limit MM to 01-12 but not 13 for instance).

I don't have a lot of experience with MaskEdit but I think you can set the mask to ##-##-####.

Come to think of it, is this a .NET control? Do they still have a MaskEdit control? Or are you saying you want to limit a textbox to the DD-MM-YYYY format programmatically?

If you want your own custom format, you can put something in the Validating event. Check the Text property against your "mask" (or use a DateTime variable to see if it's a valid, recognized format). If it fails, set the event args Cancel to true and do whatever else you want (change the BackColor, etc.).

-Ner
 
Yes, I want A mask like ##-##-####..
Wether MaskedEdit is a .NET control or Not, is a question I haven`t been able to answer my self.
In the last section of your anser, you say something about custom format. , validating and text property. Could you give me a closer description of your suggestion ? Maybe with a code example? :)
 
There is no Masked Edit control in .NET. You shouldn't use the COM one either.

I suggest you validate data using a normal textbox instead. I wrote this tutorial on doing custom validation, and it could be expanded easily using regular expressions.
 
Back
Top