cferdinandi / validate

A lightweight form validation script.
MIT License
230 stars 39 forks source link

Allow non-block styling of the error message #30

Closed robinwhittleton closed 6 years ago

robinwhittleton commented 7 years ago

Currently the code flips the error message between an inline display:block for visible and display:none for hidden. This works, but doesn’t let us apply our own display styles for the error message in our CSS (e.g. display:inline). Those styles will be overridden regardless of the error message’s state.

A better approach is to continue using display:none for the hidden state, and to simply remove it for the visible state. That way the styling will fall back to whatever display style is defined in the page’s CSS, or back to the default display for divs (block) in its absence.

The same applies for the visibility rule.

cferdinandi commented 6 years ago

I agree. This is definitely a more elegant approach.