占位符名称不在html中显示

时间:2015-03-30 07:58:03

标签: html

您好,在下面的代码占位符名称没有显示,但它显示日期格式。但我想显示两者。

预期产出:

Date Of Birth(mm/dd/yyyy)

HTML

<input type = "date" name="date_birth" pattern = "^\D{0,100}$" required = "required" class="login-input" placeholder="Date Of Birth" autofocus>

2 个答案:

答案 0 :(得分:1)

将此添加到您的css:

input[type="date"]:before {
    content: attr(placeholder);
    color: #aaa;
  }
  input
[type="date"]:focus:before,
input
[type="date"]:valid:before {
    content: "";
  }

Via- How do I simulate placeholder functionality on input date field?

答案 1 :(得分:1)

试试这个:

&#13;
&#13;
<input placeholder="Date Of Birth(mm/dd/yyyy)" class="textbox-n" type="text" onfocus="(this.type='date')"  id="date"> 
&#13;
&#13;
&#13;

演示Here

注意:它适用于Chrome。不确定关于其他浏览器。