title: Implementing simple validation on the client-side in C# ASP.NET Core 2.2
body: <p>Adding simple validation on the client-side in C# ASP.NET Core 2.2</p>
  
  <p>I've read <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-2.2" rel="nofollow noreferrer">MS docs on validation</a> and decided that it's most suitable to apply client-side validation. However, in the provided example, they show something with jQuery and I was under the impression that jQuery was getting a bit old by now. Also, we're spoiled with the nice tools from MS that will automagically do stuff for us. (I thought that the span with attribute <em>asp-validation-for</em> and div with attribute <em>asp-validation-summary</em> implied that the magic would be there. It wasn't as it turns out.)</p>
  
  <p>My code is as shown below.</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-md-4"&gt;
      &lt;form asp-controller="Security"
            asp-action="Register"
            method="post"&gt;
        &lt;div asp-validation-summary="ModelOnly" class="text-danger"&gt;&lt;/div&gt;
        &lt;div class="form-group"&gt;
          &lt;label asp-for="@Model.Email" class="control-label"&gt;&lt;/label&gt;
          &lt;input asp-for="@Model.Email" class="form-control" /&gt;
          &lt;span asp-validation-for="@Model.Email" class="text-danger"&gt;&lt;/span&gt;
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
          &lt;label asp-for="@Model.Info" class="control-label"&gt;&lt;/label&gt;
          &lt;input asp-for="@Model.Info" class="form-control" /&gt;
          &lt;span asp-validation-for="@Model.Info" class="text-danger"&gt;&lt;/span&gt;
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
          &lt;input type="submit" value="Send" class="btn btn-primary" /&gt;
        &lt;/div&gt;
      &lt;/form&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'd like to know what I'm missing to make the validation work properly (i.e. getting an error message if not both fields are filled upon submission of the form as well as the form submitting being cancelled). Alternatively, of it's something fairly basic I'm missing, I'd like to get a hint on appropriate search words. Please note that I'm only looking for the visuals: client-side messages, no relation to the back-end handler of the input.</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/37676377/client-side-validation-in-asp-net-core-mvc">some</a> <a href="https://stackoverflow.com/questions/37676377/client-side-validation-in-asp-net-core-mvc">questions</a> on the subject but since those seem not to have a resolution approved, I feel that it's best to ask in order to do things the right way instead of a guessing game.</p>