HTML5 Required input styling

前端 未结 7 1271
眼角桃花
眼角桃花 2020-11-30 11:13

In HTML 5, we can mark inputs as required and then select them with the [required] pseudo-selector in CSS. But I only want to style them when they

7条回答
  •  盖世英雄少女心
    2020-11-30 11:31

    There's a :user-error pseudoclass in the CSS Selectors 4 working draft that will do exactly this, firing on both input blur and form submit.

    In the mean time, I'm personally using the awesome webshims polyfill library which covers :user-error, or you could hack it out yourself with something along the lines of Toby's answer.

提交回复
热议问题