Input validation without success colors #3901
adwiv
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Try |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note: Post modified based on suggestions from saadeghi who offerred much better solution.
I like to use validation in my forms to highlight the invalid fields in error/red color, but really dislike that it also highlights the valid fields in green/success colors. Even when the entire form is valid, for a split second we can see the green highlights when the form is submitted. Bootstrap worked this way too.
What I want is:
Updated Solution:
Use
user-invalid:validator
instead of validator on form fields orhas[:user-invalid]:validator
if the validator is applied on an element (like label for example) that contains the field.Older Solution
On checking the code, it appears that the input highlighting is managed through--input-color
variable which gets set to --error-color if field is :user-invalid and --success-color if the field is valid. By removing the CSS for :user-valid (or reverting it) we can handle point 1. But once--input-color
gets overwritten when field is :user-invalid, we can't get back to original color as it is lost. Moreover, the original--input-color
can take a lot of different values.So the route I took is:1. Duplicate--input-color
to--input-base-color
at all the places it is being set.2. When the field is :user-valid, set the--input-color
to--input-base-color
This solution seems to be working though I haven't tested it extensively. Here are the screenshots for comparison. Both screenshots are after clicking the submit button which results in all fields being validated.~Here are the links:
CSS file for inclusion in app.cssSample with Html and CSSBeta Was this translation helpful? Give feedback.
All reactions