问题
I'm Trying Microsoft Blazor and when working with forms and validation I stopped on how can I change the default CSS class that will be added by default on InputText Validation State.
For Explanation when InputText has an error by default take class "invalid" I want to change this class to "is-invalid"
I Need best practises
Thanks, StackOverflow community
回答1:
Any HTML element (or InputText) attribute including the class, can be 'one-way' bound to a variable or expression. So in your case, you could do:
<input type="text" class="@((any_validation_condition)? "error_css_class" : "")" />
or just bind to a variable and set that variable at run-time to reflect the suitable display class of the element.
Thanks
来源:https://stackoverflow.com/questions/58199723/blazor-change-validation-default-css-class-names