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

RadMaskedTextBox empty value

3 Answers 136 Views
Input
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 05 Dec 2011, 04:46 PM
Hi,

I have a masked text box with mask '<0..3><0..3><0..3>' which displays as '000' when empty. Is it possible to have an empty text box or one which displays '___' instead?

For example:

Empty: '___'
Partially filled: '12_'
Filled: '123' 


Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Dec 2011, 06:00 AM
Hello,

Try setting Mask property as shown below.
ASPX:
<telerik:RadMaskedTextBox ID="msk" runat="server" Mask="(###)">
</telerik:RadMaskedTextBox>

Thanks,
Princy.
0
Alexander
Top achievements
Rank 1
answered on 06 Dec 2011, 09:14 AM
Hi Princy,

that does work indeed as the '#' symbol is specified as:

# DigitMaskPart Digit or space (optional). If this position is blank in the mask, it is rendered as a prompt character.

the problem is that I want to limit the ranges of the digits and not allow any digit.

Unfortunately setting the mask as '(<0..3><0..3><0..3>)' does not allow empty value also.

Thanks

Alexander
0
Vasil
Telerik team
answered on 06 Dec 2011, 04:39 PM
Hi Alexander,

You could use this workaround:
<script type="text/javascript">
  function keyPress(sender, args)
  {
    if ((args.get_keyCharacter() > "3") && args.get_keyCharacter() <= "9")
      args.set_cancel(true);
  }
</script>
<telerik:RadMaskedTextBox ID="msk" runat="server" Mask="(###)">
  <ClientEvents OnKeyPress="keyPress" />
</telerik:RadMaskedTextBox>

Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Input
Asked by
Alexander
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Alexander
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or