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

Apply Security Mask

2 Answers 69 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 14 Apr 2014, 01:58 PM
Good Morning Telerik team,

I'm trying to use the new MaskedTextInput; but I'm having trouble.  We have a business case where we need to hide certain characters in a field.  I'm binding to the Value property.  What I need to happen is:

1.  The user types 123456789 in the control
2.  When the control loses focus, I need it to display *****6789.

I've tried applying a different mask, on the lostfocus event, but that doesn't work.
I've tried binding to the text property thinking the value would stay as 123456789, but display properly.  That didn't work either.
I've also tried explicitly setting the text value, but that does one of two things.  The text value changes, but isn't displayed, or the text value is displayed, but the Value property is also *****6789 instead of the original value.

This seems like this should be simple.

Thanks!

2 Answers, 1 is accepted

Sort by
0
WILLIAM
Top achievements
Rank 1
answered on 14 Apr 2014, 05:32 PM
I have figured out a way to display the value as *****6789.  I'm not applying a mask, but looping through the string and replacing characters with a *.  I think this defeats the purpose of using the control in the first place.  The next problem is when I click in the control, the value is displayed.  There are cases where *****6789 still needs to be displayed when the control has the focus.
0
Pavel R. Pavlov
Telerik team
answered on 17 Apr 2014, 10:30 AM
Hi WILLIAM,

You can achieve your requirement by using the ValueToTextConverter property of the RadMaskedInput controls. Also, you can set the Mask property to "" (empty string) and the TextMode to PlainText

Furthermore, in your ViewModel you can create a field which will hold the real value and a boolean flag indicating which value you should visualize. Also, you can subscribe to the GotFocus event of the control and visualize the appropriate value based on the boolean flag.

For your convenience I prepared a sample project demonstrating this approach. Please take a look at it and let me know if you heave any other questions.

Regards,
Pavel R. Pavlov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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