How to apply the form input validation classes of bootstrap v4 with the ASP.NET Razor syntax?

Asked

Viewed 45 times

0

Follows code:

View:

<div class="form-group">
    @Html.LabelFor(m => m.Telefone, new { @class = "font-weight-bold" })
    @Html.TextBoxFor(m => m.Telefone, new { @class = "form-control", @placeholder = "Digite seu telefone" })
    @Html.ValidationMessageFor(m => m.Telefone, "", new { @class = "text-danger" })
</div>

Here is an example of bootstrap v4: https://getbootstrap.com/docs/4.0/components/forms/#server-side

They use the class is-invalid and is-valid. How do I do it in Razor ?

  • you want to do this so that after the post, when returning with the validation apply the class or you refer to mark as valid in real time via javascript?

  • I want to do it with Client-Side. (real time via javascript)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.