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

How to use this difficult control

2 Answers 69 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 04 Aug 2020, 02:07 PM

Reading the telerik help on this control is not very helpful at all.

I just want a maskedinput control that is the following [0-9]\+[0-5][0-9]

M+SS, so it would display --> _+__

Minutes, can be 0-9

Seconds, 00 to 59

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 07 Aug 2020, 07:16 AM

Hello John,

Two different approaches come to mind with regards to the desired functionality.  

- You can use the RadMaskedTextInput and define a Custom Mask Token for the 0-5 range. Here is how that would look:

<telerik:RadMaskedTextInput  Mask="d+$d" />

public partial class Example : UserControl
    {
        public Example()
        {
            InitializeComponent();

            
        TokenLocator.AddCustomValidationRule(new SingleDigitMinuteToken());
        }
    }

    public class SingleDigitMinuteToken : ITokenValidationRule
    {
        public bool IsRequired
        {
            get { return true; }
        }
        public bool IsValid(char character)
        {
            return ValidChars.Contains(character);
        }
        public char Token
        {
            get { return '$'; }
        }
        public TokenTypes Type
        {
            get { return TokenTypes.AlphaNumeric; }
        }

        private string myValidChars = "012345";
        public string ValidChars
        {
            get { return myValidChars; }
        }
    }

- Alternatively, since there isn't a format string that limits the minutes to single digits, you can also consider allowing double digits for the minutes with the RadMaskedDateTimeInput:

<telerik:RadMaskedDateTimeInput Mask="m+s"  />

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

0
John
Top achievements
Rank 1
answered on 07 Aug 2020, 01:59 PM
thank you so much for your example. I ended up just using a different teleric control that worked like a champ. I'm off work today, so i don't recall what the name was, I bound it to a TimeSpan and it aligned perfectly to my situation.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
John
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
John
Top achievements
Rank 1
Share this question
or