input-validation-error added to input incorrectly

Viewed 14

Why is the input-validation-error class being added to my input when it shouldn't?

Validation is working fine for other pages that actually use it. I've tried making the property nullable and using the ValidateNever attribute but both are ignored.

View Model

public class EntityTableViewModel
{
    [ValidateNever]
    public string? SearchTerm { get; set; }
}

HTML

<form method="get">
    <div class="input-group">
        <input asp-for="SearchTerm" type="search" class="form-control rounded" placeholder="Search" />
        <button type="submit" class="btn btn-primary" asp-action="Index"><i class="bi bi-search"></i></button>
    </div>
</form>

Rendered HTML

<input type="search" class="form-control rounded input-validation-error" placeholder="Search" id="SearchTerm" name="SearchTerm" value="">
0 Answers
Related