My form has two columns on wider screens and one on mobile. Inline errors shift the layout, but reserving a fixed height for every field leaves too much empty space. Is there a better option than putting errors in hover tooltips?
How do you handle error messages in a two-column form without everything shifting?
Answers
Reserve a small helper row under the input, not a fixed height for the whole field. You can use that space for a short hint when there is no error, then replace it with the error message when needed.
Give the row a minimum height of about one line rather than a fixed height. Longer messages can wrap, especially on mobile, so allow the row to grow instead of clipping the text. You could reserve the space only for fields that commonly need validation.
Reply to this answer
Let the error appear below its field and allow the grid row to grow. Use one grid for both columns rather than two independent columns, with the fields aligned to the start. The neighboring field stays at the top, and the rows below move down together.
That still causes some shift, but it keeps the form aligned without leaving empty space under every input. Validating on blur or submit instead of on every keystroke can make the change less distracting.
Reply to this answer
I'd avoid hiding the only explanation in a hover tooltip. Put the message in plain text next to the relevant field on both desktop and mobile. An icon can help draw attention, but people shouldn't have to discover or tap it just to find out what's wrong.
Reply to this answer
Native browser validation is another option if it fits the form. Calling reportValidity() can show the browser's validation message and focus the invalid input, though the presentation is controlled by the browser rather than your layout.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Tavelo.8n:
Would making the error text very small help keep that space down?
q.583~tramspoon:
I wouldn't go as small as 10px. The message needs to be easy to read, so a little extra space or movement is a better tradeoff.