This is a migrated thread and some comments may be shown as answers.

Hexadecimal digits in MaskedTextInput - autoconvert to Uppercase

3 Answers 240 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Kornelije
Top achievements
Rank 1
Kornelije asked on 03 Dec 2012, 08:56 AM
I need a masked text input to handle hexadecimal characters, of required length 6.
For example: 334CFA, 1CA039 or CA377F.

However, I have two requirements:

- User should be able to enter both lowercase and uppercase letters A-F
- The control would display only uppercase letters, even when a lowercase letter is entered.

So, user should be able to enter 15cfaD (written without shift/capslock), and the control should display: 15CFAD. The control should never display lowercase letters, but it should allow them to be input, automatically converting them to uppercase.

I've tried with a custom token, but I was only able to limit the input to 0-9A-Fa-f. This of course does not make the control display lowercase letters as uppercase.

I've tried using uppercase modifier (>) with my custom token X (Mask = ">X>X>X>X>X>X"), but it did not modify the token, it simply inserted the > characters into the input.

Is there any way to implement a custom token with TokenType.Modifier that would change the token with an arbitrary function?

How can I achieve the scenario described?

3 Answers, 1 is accepted

Sort by
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 05 Dec 2012, 10:13 AM
Hi Kornelije,

You are using the correct approach to restrict the user's input. By creating a custom token you can define a custom list of symbols as a valid input. In your case these symbols are "abcdef1234567890ABCDEF". Also you need to restrict the length of the alpha-numeric string. You can do this by setting the mask to "******" or "*6" or you can use our extensions to limit the length of the input. You can read more about our extensions here.

After creating the token (by following this article) you can use modifiers to make the text uppercase only. You can do this by setting the Mask property of the RadMaskedTextInput control to ">*6". As you can see the ">" sign is escaped and this will uppercase the user's input. I have created a sample project demonstrating the approach. Please take a look at it and let me know if it works for you.

Regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kornelije
Top achievements
Rank 1
answered on 10 Dec 2012, 08:57 AM
The only difference between your code and mine was the ITokenValidationRule.IsRequired property.

   I have set it to TRUE, because I needed all 6 characters entered. However, what happened is that the lowercase characters were converted to uppercase only when all required characters were entered (although I believe that the last character triggers the change). I needed an instant change, and it wasn't happening.

 In addition to setting the MaskedInputExtensions.MinTextLength and MaskedInputExtensions.MaxTextLength to 6, I then tried to set the IsRequired to FALSE, just as you did, and this solved the problem.

Would you be so kind as to explain why does setting the IsRequired property to one value or the other changes the behavior of the control in this way. 

Thanks
0
Pavel R. Pavlov
Telerik team
answered on 12 Dec 2012, 10:24 AM
Hello Kornelije,

Thank you for bringing this issue to our attention. I have logged it as a bug in our PITS and you can follow and vote for it here. Also I have updated your Telerik account accordingly.

Regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Kornelije
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Kornelije
Top achievements
Rank 1
Share this question
or