A validator component that compares a form input's value against another value or another component's value using a specified comparison operator. RadzenCompareValidator is commonly used for password confirmation, numeric range validation, or ensuring field values match expected criteria. Must be placed inside a RadzenTemplateForm<T> and associated with a named input component. Supports various comparison operations (Equal, NotEqual, GreaterThan, LessThan, etc.) via the Operator property. For password confirmation scenarios, set the Value property to the password field and the Component to the confirmation field name. Can react to changes in the comparison value by setting ValidateOnComponentValueChange to true (default).
ValidatorBase.GetComponentCssClass
RadzenComponent.OnAfterRenderAsync
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnInitializedAsync
ComponentBase.OnParametersSet
ComponentBase.OnParametersSetAsync
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenCompareValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormValidator<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenPassword style="display: block" Name="Password" @bind-Value=@model.Password />
<RadzenPassword style="display: block" Name="RepeatPassword" @bind-Value=@model.RepeatPassword />
<RadzenCompareValidator Value=@model.Password Component="RepeatPassword" Text="Passwords should be the same" Style="position: absolute" />
</RadzenTemplateForm>
@code {
class Model
{
public string Password { get; set; }
public double Value { get; set; }
public string RepeatPassword { get; set; }
}
Model model = new Model();
}A validator component that compares a form input's value against another value or another component's value using a specified comparison operator. RadzenCompareValidator is commonly used for password confirmation, numeric range validation, or ensuring field values match expected criteria. Must be placed inside a RadzenTemplateForm<T> and associated with a named input component. Supports various comparison operations (Equal, NotEqual, GreaterThan, LessThan, etc.) via the Operator property. For password confirmation scenarios, set the Value property to the password field and the Component to the confirmation field name. Can react to changes in the comparison value by setting ValidateOnComponentValueChange to true (default).
public RadzenCompareValidator()Specifies the comparison operator. Set to CompareOperator.Equal by default.
public CompareOperator Operator { get; set; }
| Type | Description |
|---|---|
| CompareOperator | Specifies the comparison operator. Set to CompareOperator.Equal by default. |
Gets or sets the message displayed when the component is invalid. Set to "Value should match" by default.
public string Text { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the message displayed when the component is invalid. Set to "Value should match" by default. |
Gets or sets a value indicating whether this RadzenCompareValidator should be validated on value change of the specified Component.
public bool ValidateOnComponentValueChange { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets a value indicating whether this RadzenCompareValidator should be validated on value change of the specified Component. |
Specifies the value to compare with.
public object Value { get; set; }
| Type | Description |
|---|---|
| object | Specifies the value to compare with. |
protected override void OnAfterRender(bool firstRender)
| Type | Name | Description |
|---|---|---|
| bool | firstRender |
public override Task SetParametersAsync(ParameterView parameters)
| Type | Name | Description |
|---|---|---|
| ParameterView | parameters |
| Type | Description |
|---|---|
| Task |
protected override bool Validate(IRadzenFormComponent component)
| Type | Name | Description |
|---|---|---|
| IRadzenFormComponent | component |
| Type | Description |
|---|---|
| bool |