Styling the message displayed by a custom validator for a masked numeric input control

4 posts, 0 answers
  1. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 26 Jul 2013 Link to this post

    I've put a RadMaskedNumericInput control onto window. To that I wanted to add validation. Here's the custom class I came up with:

    public class ByteValidation : ValidationRule
        private byte min = 0;
        private byte max = byte.MaxValue;
        //The Minimum and Maximum values are there to restrict how low and how high the
        //stored value can be.
        public byte Minimum
            get { return min; }
            set { min = value; }
        public byte Maximum
            get { return max; }
            set { max = value; }
        public string ErrorMessage
        { get; set; }
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
            if (value == null)
                return new ValidationResult(true, null);
            byte tmp;
                double dTmp = (double)value;
                tmp = (byte)dTmp;
            catch (Exception)
                return new ValidationResult(false, "Invalid value");
            if (tmp < min || tmp > max)
                return new ValidationResult(false, ErrorMessage);
            return new ValidationResult(true, null);

    and here's the XAML:

    <telerik:RadMaskedNumericInput Mask="##" Margin="550,0,0,0" Grid.Row="1" FontSize="16" VerticalAlignment="Bottom" FontFamily="Century Gothic">
            <Binding Path="DaysPaidLast30">
                    <local:ByteValidation Minimum="0" Maximum="30" ErrorMessage="Value must be between 0 and 30." />

    This all works fine.

    In testing I discovered that if I put in some invalid numeric data, then I'll get a gold border and a popup message. Is that color standard with the RadMaskedNumericInput? Can that be styled?

  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1237 posts

    Posted 31 Jul 2013 Link to this post

    Hi Rod,

    Let me make a quick clarification. When you input an invalid number, the control visualizes a red border. You actually see it orange when you hover or focus the RadMaskedNumericInput, because the control visualizes an yellow border when it is in Focused state. Please note that when the focus is somewhere else the border remains red.

    In order to customize that border you can change the Focused state of the control. To do that, you can extract and edit the default template of the control (read more).

    Please give this approach a try and let me know if it works for you.

    Pavel R. Pavlov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Rob Ainscough
    Rob Ainscough avatar
    188 posts
    Member since:
    Jan 2010

    Posted 16 Feb in reply to Pavel R. Pavlov Link to this post

    I'm having a similar issue, except the error text (red border to the left of the control) has a red border but the internal text is white on an almost white background making it almost impossible to read the error text in the red box (the background of the error box should be red per default for Microsoft controls like TextBox).

    I'm using a Silverlight project.  I don't see any ability to change this behavior.

    NOTE: all my other trapped Errors that are NOT Telerik controls (i.e. TextBox) show the red error box correctly ... red box outline with red background and white text, only the telerik controls shows a light almost white background???

    Any suggestions?   I'm using the latest 2017 build for Silverlight Telerik controls.

    Cheers, Rob.


  4. Evgenia
    Evgenia avatar
    1437 posts

    Posted 21 Feb Link to this post

    Hi Rob,

    This is to inform you that you have already received an answer to your inquiry on the other forum thread started by you. I suggest that we continue any further conversation on this topic there so that we avoid duplicate content in our forums.

    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top