-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Future Investments - Form validation helper improvements #4819
Comments
Very nice list, moving forward. I did implement most of these in my previous MVC5 projects, so I will share some of my thoughts. Hope it helps in some way or another
Didn't this work automatically from jQuery validation or jQuery unobtrusive validation scripts?
This one could be be achieved after hierarchical tag helpers are implemented, because it's very problematic to make it work with independent html helpers. I was wondering if MVC still tries to keep tag helper and html helper functionality the same. Because html helper's are very problematic here.
Again, would be easy with tag helper, but hard with html helpers, especially then something needs to go in between an input and it's validation span, which can't be easily expressed in html helper.
This will need a parameter of some sort, to disable/enable required glyph on specific fields or their groups. Because some of the dynamic model's don't really know if they will be required or not, until they are rendered. Or users just don't want to see required glyphs on checkboxes, even though they are "required" value type booleans on server side.
I wouldn't recommend implementing this, because it has a lot of exceptions and edge cases. It starts with "lets focus first input tag". Oh, we have very similar input tags called text areas, lets include those too. But wait, we don't really need to focus check boxes, because most of the users click them with mouse anyway. And lastly date pickers and other custom input, which get's opened/validated/loaded and whatnot by focus event, which we don't want, but can't easily exclude them too. (And I don't even want to start talking about having more than one form on the page... 😄)
Yes it does work now.
I would be great if already existing data annotation attributes would be used to indicate read only, like |
I'd also like the flag the Foundation form validation helpers: http://foundation.zurb.com/sites/docs/abide.html Ideally any solution that is devised, there shouldn't be any blockers from implementing a Bootstrap specific version, a Foundation version and a "YourFavouriteFramework" here. |
New Bootstrap v4 example for forms is another reference we should consider when we look at addressing the stuff outlined above: https://getbootstrap.com/docs/4.0/examples/checkout/ |
I was looking for a solution for this today for bs4. I'll create custom css to support the field validation for now but maybe expose the HtmlHelper.cs readonly static fields and put them in HtmlHelperOptions.cs with the default values? |
Here's what I'm proposing for a temporary solution: aspnet/Mvc@dev...michaeljbaird:exposevalidationcss |
With Core 2.2, I was able to override the default styling of the error messages by doing this in the Startup.cs file. I don't remember where I took this sample code but it worked flawlessly until I upgrade my project to Core 3.0 where I get the error message:
Any idea how I can workaround this or is there any news on how to properly override the default styling of the error message to support Bootstrap validation styles (or others)?
|
@alexandrejobin can you please file a separate issue please. We're closing this one as there has been no much community involvement here. |
We have 2020 and hardcoded css class ! WOW |
Overview
The validation helpers in MVC are due for some usability and capability improvements. We added Tag Helper-based validation helpers in the last release but they didn't really expand on the feature-set of the helpers themselves. Specifically, we're talking about the HTML Helpers and Tag Helpers that are used to enforce and show form validation on pages, including server-side and client-side validation.
Ideas
<div>
or<li>
, e.g.<div class="form-group field-validation-error">...
. This makes it much simpler to style entire form fields based on their current validation state.<form>
element itself, e.g.<form class="form-horizontal form-validation-error" ...>
. This makes it possible to style forms based on the validation state of the fields they contain.<input />
and "field-validation-valid" for the<span>
. Also, the<span>
is never represented with the initial state (untouched by user) but rather always starts as valid. This can make it difficult to achieve certain form field styles.<label for="FirstName" class="control-label form-field-required">First name:</label>
The text was updated successfully, but these errors were encountered: