ASP.Net Core: Unobtrusive validation not working
Please make sure your validation-related scripts are placed under the environment which you are using. Development Or Production.
I was struggling for some time and when I checked my script it was placed in the development section and my app was running using the production environment.
Once I placed the scripts under production it started working !
In my case the problem was quite different.
The validation scripts references were located in the default/built in _ValidationScriptsPartial.cshtml
that I was just adding to my page by adding
@section Scripts { <partial name="_ValidationScriptsPartial"/> }
at the end of my View cshtml.
I could see that it was referenced properly in Developer Tools, so I thought it's all fine:
However, it turned out that the paths in _ValidationScriptsPartial
were not correct!As you can see, there is only minified version available... and in the case of the second one, a dist
subfolder is missing.
It was quite surprising, giving this was a boilerplate code that I did not touch.