-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
input:invalid is too aggressive with type=email and others #8093
Comments
Quasi-duplicate of #1675. This is pretty much inherent to the |
The pseudo selector input:focus:invalid,
textarea:focus:invalid,
select:focus:invalid {
color: none;
border-color: none;
&:focus {
border-color: none;
}
} |
The undesirable styling behavior is coming from bootstrap and is difficult to turn off. The type=email case is especially pathological. |
I'm open to hearing more about this—perhaps we just punt it entirely and focus on the classes we have elsewhere in v3 now? |
I've completed my validation project and my opinions have hardened a bit. My vote would be to remove the :invalid rules entirely in 3.0. I don't think they can be made to work correctly, unfortunately. It's just not the right time to be turning everything red. Emphasize .has-error in 3.0 and let people apply it manually using javascript. That's what I ended up doing. For posterity, here are the SASS rules I used to disable :invalid in 2.3.1. Open to suggestions if there's a better way to do this. // turn off bootstrap's :invalid styling
input:focus:invalid,
textarea:focus:invalid,
select:focus:invalid {
color: $textColor;
border: 1px solid $inputBorder;
&:focus {
border-color: rgba(82,168,236,.8);
@include box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6));
}
}
// gotta make sure the above rules don't wipe out our REAL error case
.control-group.error {
input:focus:invalid,
textarea:focus:invalid,
select:focus:invalid {
color: $errorText;
border: 1px solid $errorText;
&:focus {
border-color: darken($errorText, 10%);
@include box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px lighten($errorText, 20%));
}
}
} |
Gone in v3. Thanks! |
* upstream/3.0.0-wip: (42 commits) Rename class name in placeholder Fixes twbs#8154: enforce full width `.navbar-nav.pull-right` in mobile Fixes twbs#8159: Be more specific about disabled inputs to avoid iOS bug Fixes twbs#8093: Removes invalid focus styles on inputs run make on previous commit Fixes twbs#7730: Better hiding of empty titles in popovers Run make on last commit Use `@font-family-base` for headings font-family variable run make on @nextgenthemes last commit rename '.navbar .nav' to '.navbar-nav' Add heading font family variable Offcanvas example update Fixes twbs#8001: add IDs for example inputs Add missing property to form-horizontal docs Add support for `tr`, `th`, and `td` to responsive utilities run make on last commit docs/javascript.html: backticks -> <code> Use correct font-size to calculate input-heights Addresses twbs#8199: darker default button Add note about Jekyll version per twbs#8195 ... Conflicts: README.md docs/assets/js/bootstrap.min.js package.json
I came across this thread when I noticed v3 inputs no longer showed the invalid state. It would be interesting to use a delayed transition to apply the invalid styles, something like this jsFiddle: http://jsfiddle.net/8QDHy/1/ With a 2-second delayed transition, the input has to be both Some caveats I didn't figure out:
|
Automatic validation styles were very useful, I really miss them. What about pull them back? They make sense when using |
This problem is known from the W3C. Here's a great post related to this issue: http://www.html5rocks.com/en/tutorials/forms/constraintvalidation/ |
IMO, it would be nice to add a CSS class to explicitly enable the :valid/:invalid styles. |
in IE invalid focus is not working..............:( |
@gautam890 Per the above conversation, the feature was removed from Bootstrap. You have to manually apply validation state classes instead (e.g. |
wow, that's tough decision. well, is there any other safe alternatives so the validation comes again on the next version. it's really helpful actually |
@mgufrone Best route at this point is probably to write a third-party plugin that toggles the Bootstrap validation state classes in response to user input & validation events. |
@cvrebert yep, i do that for this time. so when it's invalid it's adding a class on an invalid input element. |
If someone is urged to have this feature back, here's how you do it:
|
This bug is in reference to this style block from forms.less, shown below. In a nutshell, as soon you start typing into an input field with type=email the text and border instantly turn red. The user gets the following experience with that input field:
Note that the user still hasn't even finished entering their email address, even if the email address is technically legal according to the RFC. Tested with recent versions of Firefox and Chrome.
The red color is premature and scary. I need more explicit control for when the text (and border) turn red. All of the HTML5 input validation attributes result in similar problems. The rules below are a little too aggressive, in my opinion. Can we make them optional, move them into a js plugin, etc.?
The text was updated successfully, but these errors were encountered: