Тёмный
No video :(

DON'T Do This with Validation Messages!! 

James Q Quick
Подписаться 203 тыс.
Просмотров 28 тыс.
50% 1

I hate when I'm filling out a form and it jumps around as validation messages are shown. It's an easy fix. Use one line of css to give your validation message a static height. Then, you won't have shift
*Newsletter*
Newsletter 🗞 - www.jamesqquic...
*DISCORD*
Join the Learn Build Teach Discord Server 💬 - / discord
Follow me on Twitter 🐦 - / jamesqquick
Check out the Podcast - compressed.fm/
Courses - jamesqquick.co...
*QUESTIONS ABOUT MY SETUP*
Check out my Uses page for my VS Code setup, what recording equipment I use, etc. www.jamesqquic...

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 36   
@ayushdedhia25
@ayushdedhia25 10 месяцев назад
What I usually do is hide the error text by default so that its in the dom already and show it on error only.
@AbdoTech0
@AbdoTech0 10 месяцев назад
i am doing that too 😅
@BriariusTitan
@BriariusTitan 10 месяцев назад
lol same 😅
@pw.70
@pw.70 10 месяцев назад
Sometimes. Depends on the message. If it's a single message then yes, but when it can be a different messages then I use something similar to James' version.
@PhonicUK
@PhonicUK 10 месяцев назад
Two other solutions are to have the default text be a single non-breaking space, or to use "opacity: 0" to hide it which makes it invisible but still consume space in the layout. This means you don't have to consider how the height might change in different layouts or if accessibility features change the size of elements.
@JamesQQuick
@JamesQQuick 10 месяцев назад
Yep, lots of different good options. Just avoid the layout shift lol
@xphstos_
@xphstos_ 4 месяца назад
That works only if you know before hand the message would take only one line of space and when you have pre-rendered. For non pre-render content and with unknown height your only choice is to position absolute it at the bottom of your label/field. That also has its caveats, for example it might end up covering part of the next field if your spacing is not enough or the message too long. Another safe choice is to show something like a tippyjs box. You can appear an icon indicating something is wrong and you can have the tippy open by default or trigger it on hover. Not very common but if your primary language is not simple as English or your messages are quite verbose you can do that. But then again if you have needs like that probably the jumpyness of the form is not your main issue.
@taylorsabbag6962
@taylorsabbag6962 7 месяцев назад
This is an important point, but I think setting a specific height might lead to problems if font-size changes. visibility: hidden; feels like the most idiomatic way of doing this, as it still retains its space in the DOM, unlike display: none;.
@hamdaniash-siddiq5021
@hamdaniash-siddiq5021 3 месяца назад
i think this is still preserve the issue if we display the error message based on a condition (lets say based on a state). I think the better solutuion is to make wrapper for both the field and the error and set the wrapper to relatiove so that we can set the error style to absolute and set its position based on the relative parent. with this approach, the error element will never distract any element that sits near it. This is what exactly i do today in my office when i see the previous dev make the error message go wild from the field where it belongs.
@nickwoodward819
@nickwoodward819 10 месяцев назад
Nice. Prefer to make them absolute though, they tend to make the form look meh when they *aren't* visible. Would rather the design was tight when they're there, rather than loose when they aren't :)
@JamesQQuick
@JamesQQuick 10 месяцев назад
Yep i get that too! That’s a great option!
@nickwoodward819
@nickwoodward819 10 месяцев назад
@@JamesQQuick Love your stuff btw 👍
@JamesQQuick
@JamesQQuick 10 месяцев назад
Thank you so much!@@nickwoodward819
@shakiltech1
@shakiltech1 6 месяцев назад
You can also show the default hint at first and update it with an error so it doesn't look weird space.
@bloodylupin
@bloodylupin 2 месяца назад
if viewport is too short and the line breaks you end with a truncated error, setting fixed heights brings always bugs.
@asaphhere
@asaphhere 10 месяцев назад
Great content! Quick and well explained. Subscribed
@JamesQQuick
@JamesQQuick 10 месяцев назад
So glad to hear that!
@tomasprieto9746
@tomasprieto9746 4 месяца назад
There are bigger UX mistakes on the former than that. For one, you’re making your user guess what the requirements are before he gets an error message.
@SpaghettiRealm
@SpaghettiRealm 7 месяцев назад
I think validation on blur is the worst thing
@pw.70
@pw.70 10 месяцев назад
It's a pet hate of mine, too. I go out of my way to fix crap like this.
@JamesQQuick
@JamesQQuick 10 месяцев назад
lol good stuff!
@thekingdev4675
@thekingdev4675 10 месяцев назад
I use position absolute
@JamesQQuick
@JamesQQuick 10 месяцев назад
Yeah that's another good option!
@user-qz8hz4es5c
@user-qz8hz4es5c 8 месяцев назад
what if validation message has different messages?
@Diosdaddy
@Diosdaddy 9 месяцев назад
You don’t need to use hacks like this, there’s property made for this exact purpose: visibility:hidden
@itsaydrian
@itsaydrian 10 месяцев назад
Fine. I’ll do it for you.
@JamesQQuick
@JamesQQuick 10 месяцев назад
Thanks :)
@zeroregretsgiven
@zeroregretsgiven 8 месяцев назад
Lol, you do a video about that? Thanks, captain obvious.
@Stoney_Eagle
@Stoney_Eagle 10 месяцев назад
Already beat you to it 😂 that annoys me too
@JamesQQuick
@JamesQQuick 10 месяцев назад
lol yeah same here!
@svenmify
@svenmify 4 месяца назад
Can someone explain to me how tailwind is any different from inlining styles? Seems like it’s a huge step backwards, adding clutter and repetition to the html again, instead of keeping it clean.
@jaishkhan7442
@jaishkhan7442 3 месяца назад
Inline Styles are actually faster lmao
Далее
JavaScript Client-side Form Validation
29:07
Просмотров 713 тыс.
Use these instead of vh
6:06
Просмотров 505 тыс.
ASMR Programming - Animated Login Page - No Talking
18:18
My Problem with Using TypeScript in 2023
8:15
Просмотров 16 тыс.
The Secret Science of Perfect Spacing
9:40
Просмотров 414 тыс.
Using CSS custom properties like this is a waste
16:12
Просмотров 169 тыс.
When RESTful architecture isn't enough...
21:02
Просмотров 275 тыс.