I have a simple EditForm within a Blazor Server Side application. It has an bound property which changes another property which should also be validated by the form.
The form contains the following section
<div class="form-group col-md-6">
<label for="inputRechnungsnummer">Rechnungsnummer</label>
<InputNumber @bind-Value="Input.Rechnungsnummer" id="inputRechnungsnummer" class="form-control" />
<ValidationMessage For="() => Input.CustomerExists" />
<ValidationMessage For="() => Input.Rechnungsnummer" />
</div>
As you can see, I want to display two messages under this InputField.
The bond field calls a method to find customer details.
public int Rechnungsnummer
{
get => _rechnungsnummer;
set
{
_rechnungsnummer = value;
SearchKunde();
}
}
This method changed the value of my attribute
private void SearchKunde()
{
/* LOGIC */
if(name != null)
{
Kundenname = name;
CustomerExists = true;
}
else
{
Kundenname = "";
CustomerExists = false;
}
}
The second attribute is defined as:
[Required]
[Range(typeof(bool), "true", "true", ErrorMessage = "Bitte geben Sie eine gültige Rechnungsnummer ein")]
public bool CustomerExists { get; set; }
However the validation message for CustomerExists won't be displayed. It is only shown once I try to submit my form.
Does anybody know how I can achive to display the message after it's value has been changed?