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

RadMaskedTextBox behavior

1 Answer 91 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Elias
Top achievements
Rank 1
Elias asked on 25 Jan 2011, 06:50 PM
Hello,

I am using the RadMaskedTextBox to display a mask for a Social Security Number field, but I would like to display the mask only when the textbox has the focus.  When the textbox has the focus the mask should be displayed, such as ___-__-____.  If the user enters a number of values, the mask should still be displayed along with the values entered such as 415-74-____. If the user does not enter any values or deletes these values, the mask should not be displayed. Is this possible using the RadMaskedTextBox? 

This brings a couple of issues to mind:

1. When the mask is constantly displayed in a field that is not required or doesn't need to be validated, the RadMaskedTextBox will send the mask characters to the database field.  The developer then needs to code for the mask as in:

if

 

 

(SSN == "___-__-____")
    SSN =
string.Empty;

I don't feel as though this is proper.  Is there a way around this? Can the mask be displayed only when values exists?

 

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 31 Jan 2011, 08:31 AM
Hi Elias,

RadMaskedTextBox does not return the literal (-) or prompt (_) characters in its Text property. Only the user-entered value is returned, stripped of any literals in the mask itself. I have attached a small test page to demonstrate. Enter some digits and click the button to have the label show the RadMaskedTextBox.Text property.

Hiding the mask when the textbox is not focused is not supported. You can display a different mask when RadMaskedTextBox is blurred by setting the DisplayMask property, but you cannot remove the mask completely.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Elias
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or