Jump to content

Clear button in input field to appear only if there is text


TonyR

Recommended Posts

If you keep the input as required then you can use the :valid/invalid CSS selectors.

input:invalid + #clear { visibility: hidden; }

Separately, you shouldn't make the clear button use an ID because then you can't have more than one on a page. At least 90% of the time, if you're thinking of using an ID you should probably use a class instead.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.