1

I have an MVC project and im using vue for my application form.

<div class="validation-error" ref="message">@Html.ValidationMessageFor(m => m.Title)</div>
<div class="label-container">@Html.LabelFor(m => m.Title)</div>   
<div class="form-control">@Html.TextBoxFor(m => m.Title, new { v_model = "val", @ref = "field" })</div>

which is a text box with a validation message bounded to it. Im wondering if I can change the colour of the text box only if the validation message is active.

I saw the html renders an attribute called aria-invalid="true" so im wondering if I could use v-if or something.

Thanks

1 Answer 1

3

Yes, see the Class and Style Bindings section of the Vue.js documentation.

Here's an example of a class that is enabled or disabled based on the truthiness of a Vue.js variable:

<div :class="{ 'css-class-name': isActive }"></div>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.