Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# ASP.NET MVC Forms Adding Form Validation Implementing Unobtrusive Client-Side Validation

Alan Mills
Alan Mills
31,712 Points

client-side validation isn't appearing to function.

I followed the code-along, pulled the jquery files, via NuGet, and checked for typos.

in WebConfig: <add key="UnobtrusiveJavaScriptEnabled" value="true" /> <add key="ClientValidationEnabled" value="true" />

in Shared/Layout: <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

I'm still hitting the breakpoint when I shouldn't. Has anybody experienced anything similar? Could use a hand. Thanks!

I have noticed the same problem. The client side obtrusive validation is not working. There one additional step in the teachers notes when compared to the steps in the video like adding of the code. It still does not work. Client side validation should fire, show the error message and form should not post to the server.

@RenderSection("scripts", required: false)
Alan Mills
Alan Mills
31,712 Points

So, I've ended up forking the suggested Treehouse Repo, and I'm now seeing client-side validation. But I'd love to diff my two repos, so I can identify what slight-of-hand is going on, preventing my own client-side validation to fail. Any advice is greatly appreciated. Thanks!!!

2 Answers

Harald Carlsten
Harald Carlsten
7,806 Points

I also had this problem but I didn't start to copy code. Instead, I tried to look the error messages... I found that the script was referring to a non-existent version of JQuery. I hooked up to the JQuery in the Application (3.3.1) and then everything was alright in this best of worlds...

Chris Roberts-Watts
Chris Roberts-Watts
5,434 Points

I have had the exact same issue, I downloaded the project files and used v4.6 to compare against. Everything was identical (at least I think it was). So I copy and pasted the script includes from the bottom of the layout view, copy and pasted the app settings from the top of the web config file, rebuilt it and it worked .... no idea what was different but if your struggling and want to keep your own project if you have made personal changes give that a go.

Thanks! Came here because I just ran into the same problem and that solution worked. Mine also looked identical, so not sure what is going on here.