Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design a better validation experience for MVC #8573

Open
3 tasks
danroth27 opened this issue Mar 15, 2019 · 30 comments
Open
3 tasks

Design a better validation experience for MVC #8573

danroth27 opened this issue Mar 15, 2019 · 30 comments
Assignees
Labels
affected-medium This issue impacts approximately half of our customers area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-mvc-razor-views Features related to the Razor view engine for Razor pages and MVC views needs-prototype Priority:2 Work that is important, but not critical for the release severity-major This label is used by an internal tool
Milestone

Comments

@danroth27
Copy link
Member

danroth27 commented Mar 15, 2019

#8573 (comment) covers the problem statement for this issue


Bootstrap 5 is removing it's dependency on jQuery: twbs/bootstrap#23586

This issue tracks investigating what removing jQuery as a dependency from ASP.NET Core would take.

We're going to split this work into two phases:

  1. Design the new JS library to replace jquery-validation-unobstrusive
  2. Implement the above
  3. HTMLHelper default css class names #17412
@muratg muratg added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Mar 15, 2019
@mkArtakMSFT
Copy link
Member

@ryanbrandenburg can you please investigate and come up with some cost for this work? Thanks!

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Mar 19, 2019
@mkArtakMSFT
Copy link
Member

@danroth27 seems we rely on jQuery for our validation too, it's not just transitive because of Bootstrap dependency.

@danroth27
Copy link
Member Author

danroth27 commented Mar 26, 2019

@mkArtakMSFT Right, the main work item tracked by this issue is investigating what it would take to remove the jQuery dependency from our validation support.

@danroth27
Copy link
Member Author

Given that our current validation support is built on jQuery validation, the way I would think about this issue is to take a fresh look at what our client validation support should look like. Is there a different validation library that we should consider using? Etc.

@ryanbrandenburg
Copy link
Contributor

The one option that seems to be most popular (and standards compliant) would be using the built-in HTML5 form validation. The problem there is that it would only work for client-side validation. As far as I can tell HTML5 form validation doesn't solve any server-side validation problems, and even if it did it would require a lot of changes to DataAnnotations. HTML5 also isn't supported on older browsers (IE9 was the example I found).

In my opinion it's not worth the work that would be required to remove our dependencies here in the absence of a more unified vision about what value we can produce from re-working DataAnnotations.

@mkArtakMSFT mkArtakMSFT added Priority:2 Work that is important, but not critical for the release and removed Priority:1 Work that is critical for the release, but we could probably ship without labels Nov 10, 2022
@sanamhub
Copy link

This issue is still unplanned?! wow..

@jerriep
Copy link

jerriep commented Dec 21, 2023

@sanamhub I doubt this will ever happen. It seems obvious that Blazor is the new flavour-of-the-month UI framework at MS, and it has a validation story built-in. I doubt you can expect any enhancements on the MVC and Razor Pages side going forward - unless it happens as a byproduct of their work on Blazor.

So, I suggest you look at alternatives. That's what I did since my comment on this issue more than 3 years ago.

@lonix1
Copy link
Contributor

lonix1 commented Dec 21, 2023

@jerriep What alternative are you using?

@jerriep
Copy link

jerriep commented Dec 21, 2023

@lonix1 I am using React for my frontends now, primarily because of the massive ecosystem of libraries and components. If you want to stay in the .NET world, I suppose Blazor is the proper alternative. If you are locked into using MVC/Razor Pages, then you should probably look at something like https://github.com/haacked/aspnet-client-validation, which I mentioned earlier in this thread - it seems well-maintained.

@sanamhub
Copy link

sanamhub commented Dec 26, 2023

cc @danroth27 @MackinnonBuck

@dahlbyk
Copy link
Contributor

dahlbyk commented Dec 29, 2023

It seems reasonable to continue iterating on https://github.com/haacked/aspnet-client-validation rather than reinvent a first-party equivalent. We still haven't shipped 1.0, so breaking API feedback is welcome. Need a nonzero testing story, too. Sponsors? 😁

#34777 was a great solution to #17412 (other than deleting public members that should be marked [Obsolete] instead). The documentation for the new properties should include a warning like:

Changing this value is incompatible with jQuery Unobtrusive Validation 4.x and lower.

...with a link to docs that can be updated to reflect the current state of the art. That may eventually be "it Just Works™️ with jUV 5.x or aspnet-client-validation" but in the meantime it can enumerate known limitations/options.

I don't think anyone is surprised that updating jUV isn't a top priority for the team, but waiting on a perfect solution has thus far meant there's no solution (except reflection). A well-documented optional configuration seems like a great first step that can be mostly community-driven.

@captainsafia captainsafia modified the milestones: .NET 8 Planning, Backlog Mar 1, 2024
@mkArtakMSFT mkArtakMSFT added area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Apr 30, 2024
@jburkett
Copy link

jburkett commented Jul 4, 2024

Can we at least get jQuery removed from the template? Encouraging use of jQuery should be considered an active bad, in and of itself, at this point. Experienced web developers will have no problem using web standards or finding a replacement package (say, https://github.com/haacked/aspnet-client-validation). Novice developers are hindered in their growth by promoting the use of libraries that have been outdated for the better part of a decade.

@sanamhub
Copy link

sanamhub commented Jul 4, 2024

Any updates in this?

@lonix1
Copy link
Contributor

lonix1 commented Jul 4, 2024

There haven't been updates for over a decade; doubt that'll change.

Use https://github.com/haacked/aspnet-client-validation instead. You can then toss out jQuery, jQuery Validation and jQuery Unobtrusive Validation. It's a drop-in replacement, works perfectly, is actively maintained, has more features, and is much easier to use.

@Neutrino-Sunset
Copy link

There's a great tutorial on how to use aspnet-client-validation here.

Can anyone explain the cause of all the navel gazing here? Doesn't addressing this consist of nothing more complicated than updating the ASP Core project template to use a newer and better library that already exists?

To me this comes across as the usual MS attitude of 'we aren't going to fix this because we are already working on something new' (Blazor?), which I think is the main reason why most developers choose to use frameworks written by anyone other than MS.

@andkorsh
Copy link

@Neutrino-Sunset especially for identity templates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-medium This issue impacts approximately half of our customers area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-mvc-razor-views Features related to the Razor view engine for Razor pages and MVC views needs-prototype Priority:2 Work that is important, but not critical for the release severity-major This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests