question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Beginner issue: Can't get client side validation to work

See original GitHub issue

I can’t get RequiredIf validation in my ASP.NET MVC 5 application to fire on the client (it always posts back to the server).

I added the following to Application_Start

DataAnnotationsModelValidatorProvider.RegisterAdapter(
    typeof(RequiredIfAttribute), typeof(RequiredIfValidator));
DataAnnotationsModelValidatorProvider.RegisterAdapter(
    typeof(AssertThatAttribute), typeof(AssertThatValidator));

and my page contains the script reference to: expressive.annotations.validate.js

I get the correct validation error messages, but it always posts back to the server to get them.

Thanks for any help; I appreciate it.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jwaliszkocommented, Mar 14, 2016

As your generated scripts section shows, jquery.validate.js and jquery.validate.unobtrusive.js are loaded twice. Remove that redundancy and check then.

0reactions
jwaliszkocommented, Mar 14, 2016

Good it works 😃 Regards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

asp.net mvc client side validation not working?
For some reason the Html helpers does not have generated validation attributes in the inputs (data-val="true" and the others), check that.
Read more >
Client-side form validation - Learn web development | MDN
So why do we insist on validating our forms? There are three main reasons: We want to get the right data, in the...
Read more >
Part 85 Enable client side validation in asp net mvc - YouTube
Otherwise, client side validation will not work. ... validation does not work, but server side validation will continue to work as normal.
Read more >
Adding client-side validation to ASP.NET Core, without ...
In this article I describe how to use the aspnet-client-validation library to provide client-side validation instead of relying on jQuery.
Read more >
When client and server side validations occur, doesn't it ...
I find a problem on the MVC4 project I am working on now, using Fluent Validation, in that some validations are delegated to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found