How do I simulate placeholder functionality on input date field?

后端 未结 14 1428
生来不讨喜
生来不讨喜 2020-11-27 03:35

It\'s impossible to use placeholder on date fields but I really need it.

I want two date inputs with texts \"From\" and \"To\" on each one as placeholders.

14条回答
  •  無奈伤痛
    2020-11-27 04:20

    CSS

    input[type="date"] {position: relative;}
    input[type="date"]:before {
    	position: absolute;left: 0px;top: 0px;
    	content: "Enter DOB";
    	color: #999;
    	width: 100%;line-height: 32px;
    }
    input[type="date"]:valid:before {display: none;}

提交回复
热议问题