Input validation without success colors #3901
Replies: 2 comments 4 replies
-
|
Try |
Beta Was this translation helpful? Give feedback.
-
|
How to apply these variants when label text is inside input? I tried adding The first option works for the normal |
Beta Was this translation helpful? Give feedback.
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:validatorinstead of validator on form fields orhas[:user-invalid]:validatorif 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-colorvariable 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-colorgets overwritten when field is :user-invalid, we can't get back to original color as it is lost. Moreover, the original--input-colorcan take a lot of different values.So the route I took is:1. Duplicate--input-colorto--input-base-colorat all the places it is being set.2. When the field is :user-valid, set the--input-colorto--input-base-colorThis 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