This is my first time using the masked input and I could use some help. I don't want the placeholder, so I'm using Mask="". In this example, I want to restrict to positive integers only (or blank if it's an optional input). I can restrict the numeric version to digits only, but how do I prevent the negative sign?
I would actually prefer to use the normal masked input and simply limit it to the characters 0-9. However when I use Mask="", I have not been able to restrict the inputs using the FormatString. It's still allowing me to type anything.
7 Answers, 1 is accepted
To restrict the input to be only positive numbers you can set the MaskedInputExtensions.Minimum attached property to 0.
<
telerik:RadMaskedNumericInput
maskedInput:MaskedInputExtensions.Minimum
=
"0"
/>
Regards,
Dinko
Telerik by Progress
I am not sure that I have correctly understood your requirement. I would ask you to elaborate more on what you do you mean by "I can't get the FormatString to restrict any input." . Also which mask (RadMaskedTextInput, RadMaskedNumericInput etc.) are you using?
Regards,
Dinko
Telerik by Progress
Sorry, I've been really busy. As an example, I want to limit the input to two characters from 0-9. So the user should be allowed to type anything from 0 to 99. I do not want a placeholder, so in all instances, Mask="".
I want to use RadMaskedTextInput. What values are allowed in the FormatString to control the input? The documentation states that this control can use No-mask, but doesn't state how to use FormatString with it.
http://docs.telerik.com/devtools/wpf/controls/radmaskedinput/features/common
I've tried setting the FormatString to the following values, but none of them affect what the user is allowed to type.
AA
00
For a completely different non-numeric example, I want to restrict the user to entering only one letter (A-Z). How would I do that using no-mask?
Using the FormatString property of the control you can't restrict the input. From your last reply, we assumed that you are using because you don't want placeholders. If this is the case you can use the Placeholder property and override the default value. You can check the Placeholder help article in our documentation where this property is further described. Below you can check two suggestion which you can try for the mentioned approach in your last reply.
In you first approach you want to restrict the input to positive number from 0 to 99. You can use the RadMaskedNumericInput with the MaskedInputExtensions.Minimum attached property setting to 0 and Mask property set to "AA" to restrict the input to two numbers.
<
telerik:RadMaskedNumericInput
Mask
=
"AA"
Width
=
"250"
Placeholder
=
" "
maskedInput:MaskedInputExtensions.Minimum
=
"0"
/>
For the non-numeric input, you can use RadMaskedTextInput control. Here you can set the mask to "L1" so only one letter can be enter. In addition, you can add Upper token to the mask so that the entered letter always is upper case. You can check the Modifier Tokens section in the Mask Tokens help article.
<
telerik:RadMaskedTextInput
Mask=">L1" Width="250" Placeholder=" "/>
Give this approaches a try and let us know if they work for you.
Dinko
Telerik by Progress
I think it's not possible. Setting the placeholder to a space then shows spaces in the textbox which is not acceptable. The documentation states that using no-mask with RadMaskedTextInput is possible (true), but it appears if you do that, it's impossible to control the input. However you *can* control it when using the RadMaskedNumericInput. If that's true, the documentation should be corrected.
I've seen several posts of people trying to get rid of the placeholder so I would suggest allows no placeholder while using the Mask.
For non-numeric input restriction, I will just use a normal text box and validate the user's text myself.
Thank you for your feedback. We appreciate any feedback given from our customers. We have logged this article in our backlog for further updating.
Another approach wich you can try to clear the placeholder is to create a custom style and set the Placeholder to a Zero Width No-Break Space Unicode character. For example:
<
Style
TargetType
=
"telerik:RadMaskedTextInput"
>
<
Setter
Property
=
"Placeholder"
>
<
Setter.Value
>

</
Setter.Value
>
</
Setter
>
</
Style
>
Hope this is helpful.
Regards,
Dinko
Telerik by Progress