I was wondering if .NET core's asp-validation-for has a way to override the class that gets set on a span, or if there is a way to extend the tag helper to allow for that. Right now, when an error occurs client side, field-validation-error
is the class that gets put on my span element. I was wondering if there is a way to override that within .NET Core or if I'll have to develop/modify that myself? This seems like a silly shortcoming, and I'd be surprised if there wasn't some other way of getting what I'm looking for.
The problem is I'm using bootstrap, and I want to add some bootstrap classes to my error element when a form doesn't pass validation.
Have a look at the HTML it generates, which may differ on the version you have; with me, like with you for me it generates:
So, the only thing I have to do is style the .field-validation-error class in ccs. as I normally do not have it as it's not generated in the File New Project template I just add it according to the specifications.
so in my site.css, I add
I usually also edit the input itself; assuming you also want to do that you could do something like this, adding a (!) error marker in the right side of the input:
And things start to become better, You can go "creative" on CSS, you could use a global approach if your style guide allows it and state that:
Every Input, when Focused (say selected by the user) and is invalid then:
this would be for each input that is detected by the browser and your css is actually loaded.