Skip to main content
All docs
V25.2
  • DxMaskedInput<T>.ValueChanging Event

    Fires when the Masked Input’s value is being modified. Use this event to validate/cancel user input.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.2.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    [Parameter]
    public Action<ParameterValueChangingEventArgs<T>> ValueChanging { get; set; }

    Event Data

    The ValueChanging event's data class is ParameterValueChangingEventArgs<T>. The following properties provide information specific to this event:

    Property Description
    NewValue Gets or sets the new value being assigned to the parameter.
    OldValue Gets the current parameter value.

    Remarks

    The ValueChanging event fires before a new value is applied to the editor (before the ValueChanged event). You can use this event to validate/cancel user input.

    The following code snippet applies the Currency mask and handles the ValueChanging event to limit the value range (0 - 1000). The current value is updated via two-way binding (@bind-Value).

    <DxMaskedInput @bind-Value="@Amount"
                   ValueChanging="@OnValueChanging"
                   Mask="@NumericMask.Currency">
    </DxMaskedInput>
    
    <div class="mt-2">
        <span>Current amount: @Amount.ToString("C")</span>
    </div>
    
    @code {
        decimal Amount { get; set; }
    
        private void OnValueChanging(ParameterValueChangingEventArgs<decimal> e) {
            if (e.NewValue < 0 || e.NewValue > 1000) {
                e.NewValue = e.OldValue;
            }
        }
    }
    
    See Also