Demos About Radzen
Search Results for

    Show / Hide Table of Contents

    Class RadzenNumericRangeValidator

    A validator component that ensures a numeric value falls within a specified minimum and maximum range. RadzenNumericRangeValidator is ideal for quantity limits, age restrictions, price ranges, or any bounded numeric input. Must be placed inside a RadzenTemplateForm<TItem>. Ensures values are within acceptable bounds by checking that the value is greater than or equal to Min and less than or equal to Max. Both bounds are inclusive. You can specify just Min to validate minimum value (e.g., age must be at least 18), just Max to validate maximum value (e.g., quantity cannot exceed 100), or both to validate range (e.g., rating must be between 1 and 5). Works with any IComparable type (int, decimal, double, DateTime, etc.). Set AllowNull = true to accept null values as valid (for optional nullable fields).

    Inheritance
    object
    ComponentBase
    RadzenComponent
    ValidatorBase
    RadzenNumericRangeValidator
    Implements
    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    IRadzenFormValidator
    Inherited Members
    ValidatorBase.messages
    ValidatorBase.SetParametersAsync(ParameterView)
    ValidatorBase.GetComponentCssClass()
    ValidatorBase.Dispose()
    ValidatorBase.BuildRenderTree(RenderTreeBuilder)
    ValidatorBase.Form
    ValidatorBase.Component
    ValidatorBase.Popup
    ValidatorBase.IsValid
    ValidatorBase.EditContext
    RadzenComponent.OnMouseEnter()
    RadzenComponent.OnMouseLeave()
    RadzenComponent.OnContextMenu(MouseEventArgs)
    RadzenComponent.GetCssClass()
    RadzenComponent.GetId()
    RadzenComponent.Debounce(Func<Task>, int)
    RadzenComponent.OnInitialized()
    RadzenComponent.OnAfterRenderAsync(bool)
    RadzenComponent.RaiseContextMenu(MouseEventArgs)
    RadzenComponent.RaiseMouseEnter()
    RadzenComponent.AddContextMenu()
    RadzenComponent.RaiseMouseLeave()
    RadzenComponent.Attributes
    RadzenComponent.Element
    RadzenComponent.MouseEnter
    RadzenComponent.MouseLeave
    RadzenComponent.ContextMenu
    RadzenComponent.Culture
    RadzenComponent.DefaultCulture
    RadzenComponent.Style
    RadzenComponent.Visible
    RadzenComponent.UniqueID
    RadzenComponent.JSRuntime
    RadzenComponent.IsJSRuntimeAvailable
    RadzenComponent.Reference
    RadzenComponent.CurrentStyle
    ComponentBase.OnInitializedAsync()
    ComponentBase.OnParametersSet()
    ComponentBase.OnParametersSetAsync()
    ComponentBase.StateHasChanged()
    ComponentBase.ShouldRender()
    ComponentBase.OnAfterRender(bool)
    ComponentBase.InvokeAsync(Action)
    ComponentBase.InvokeAsync(Func<Task>)
    ComponentBase.DispatchExceptionAsync(Exception)
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Radzen.Blazor
    Assembly: Radzen.Blazor.dll
    Syntax
    public class RadzenNumericRangeValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormValidator
    Examples

    Age minimum validation:

    <RadzenTemplateForm TItem="Model" Data=@model>
        <RadzenNumeric Name="Age" @bind-Value=@model.Age />
        <RadzenNumericRangeValidator Component="Age" Min="18" Text="Must be 18 or older" Style="position: absolute" />
    </RadzenTemplateForm>

    Quantity range validation:

    <RadzenTemplateForm TItem="Model" Data=@model>
        <RadzenNumeric Name="Quantity" @bind-Value=@model.Quantity />
        <RadzenNumericRangeValidator Component="Quantity" Min="1" Max="100" 
                                      Text="Quantity must be between 1 and 100" Style="position: absolute" />
    </RadzenTemplateForm>

    Constructors

    RadzenNumericRangeValidator()

    A validator component that ensures a numeric value falls within a specified minimum and maximum range. RadzenNumericRangeValidator is ideal for quantity limits, age restrictions, price ranges, or any bounded numeric input. Must be placed inside a RadzenTemplateForm<TItem>. Ensures values are within acceptable bounds by checking that the value is greater than or equal to Min and less than or equal to Max. Both bounds are inclusive. You can specify just Min to validate minimum value (e.g., age must be at least 18), just Max to validate maximum value (e.g., quantity cannot exceed 100), or both to validate range (e.g., rating must be between 1 and 5). Works with any IComparable type (int, decimal, double, DateTime, etc.). Set AllowNull = true to accept null values as valid (for optional nullable fields).

    Declaration
    public RadzenNumericRangeValidator()
    Examples

    Age minimum validation:

    <RadzenTemplateForm TItem="Model" Data=@model>
        <RadzenNumeric Name="Age" @bind-Value=@model.Age />
        <RadzenNumericRangeValidator Component="Age" Min="18" Text="Must be 18 or older" Style="position: absolute" />
    </RadzenTemplateForm>

    Quantity range validation:

    <RadzenTemplateForm TItem="Model" Data=@model>
        <RadzenNumeric Name="Quantity" @bind-Value=@model.Quantity />
        <RadzenNumericRangeValidator Component="Quantity" Min="1" Max="100" 
                                      Text="Quantity must be between 1 and 100" Style="position: absolute" />
    </RadzenTemplateForm>

    Properties

    AllowNull

    Gets or sets whether null values should be considered valid. When true, null values pass validation (useful for optional nullable fields). When false (default), null values fail validation.

    Declaration
    [Parameter]
    public bool AllowNull { get; set; }
    Property Value
    Type Description
    bool

    true to allow null values; false to require a value. Default is false.

    Max

    Gets or sets the maximum allowed value (inclusive). The component value must be less than or equal to this value. Can be null to only validate minimum. Works with any IComparable type (int, decimal, DateTime, etc.).

    Declaration
    [Parameter]
    public IComparable Max { get; set; }
    Property Value
    Type Description
    IComparable

    The maximum value, or null for no maximum constraint.

    Min

    Gets or sets the minimum allowed value (inclusive). The component value must be greater than or equal to this value. Can be null to only validate maximum. Works with any IComparable type (int, decimal, DateTime, etc.).

    Declaration
    [Parameter]
    public IComparable Min { get; set; }
    Property Value
    Type Description
    IComparable

    The minimum value, or null for no minimum constraint.

    Text

    Gets or sets the error message displayed when the value is outside the valid range. Customize to provide specific guidance (e.g., "Age must be between 18 and 65").

    Declaration
    [Parameter]
    public override string Text { get; set; }
    Property Value
    Type Description
    string

    The validation error message. Default is "Not in the valid range".

    Overrides
    ValidatorBase.Text

    Methods

    Validate(IRadzenFormComponent)

    Runs validation against the specified component.

    Declaration
    protected override bool Validate(IRadzenFormComponent component)
    Parameters
    Type Name Description
    IRadzenFormComponent component

    The component to validate.

    Returns
    Type Description
    bool

    true if validation is successful, false otherwise.

    Overrides
    ValidatorBase.Validate(IRadzenFormComponent)

    Implements

    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    IRadzenFormValidator

    Introducing Radzen Blazor Studio

    Radzen Blazor Studio is a software development environment that empowers developers to design, build and deploy Blazor applications without the traditional hurdles. Write less code and get more done.

    Learn More

    Download Now
    Download Now
    In This Article
    Back to top Radzen Blazor Components, © 2018-2025 Radzen. Source Code licensed under MIT