I am using Asp.net Core MVC. I have a property that has the data annotation of required.
property:
[Required(ErrorMessage = "O campo SEXO é obrigatório")]
public SEXO Sexo { get; set; }
enum:
public enum SEXO {
MASCULINO = 0,
FEMININO = 1
}
select element
<select asp-for="Sexo" class="form-control">
<option value="">SELECIONE</option>
<option value="0">Homem</option>
<option value="1">Mulher</option>
</select>
When I enter some text in a text input field and erase it the required message appears. But when I select an option in a select element that has a value that is no considered empty like:
<option value="0">Homem</option>
And afterwards change it back to
<option value="">SELECIONE</option>
The required message doesn't appear. This make the user experience very uneven. Is there some easy way to fix this or I will have to fire some Javascript.