How to use this difficult control

3 posts, 1 answers
  1. John
    John avatar
    23 posts
    Member since:
    Nov 2017

    Posted 04 Aug Link to this post

    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. Answer
    Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    707 posts

    Posted 07 Aug Link to this post

    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

  3. John
    John avatar
    23 posts
    Member since:
    Nov 2017

    Posted 07 Aug in reply to Vladimir Stoyanov Link to this post

    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.
Back to Top