1
votes

I'm creating an ASP.NET Core MVC Web App and have a form with multiple steps.
I'm using javascript to hide/show steps after user click Next/Previous button.
My ViewModel has Validation Attributes like this

public class BookViewModel
{
  [Required(ErrorMessage = "Please enter book title")]
  public string BookTitle { get; set; }
  [Required(ErrorMessage = "please enter author name")]
  public string Authors { get; set; }
...
}

and in view I use Tag Helper for client side validation

<input asp-for="BookTitle" class="form-control" />
<span asp-validation-for="BookTitle" class="text-danger"></span>
...

I want to fire validation after each steps, when user click Next button. But it only fire when user submit form at the final steps.
How can I do that?

1

1 Answers

0
votes

How to trigger ASP.NET client-side validations without submit?

go through above link, you will get more clear with the validation.