Ely*_*yor 4 html5 date placeholder
占位符不能直接用于输入类型日期.
<input required="" type="text" class="form-control" placeholder="Date"/>
Run Code Online (Sandbox Code Playgroud)
相反,它显示mm/dd/yyy
如何显示日期?
Ely*_*yor 24
使用onfocus="(this.type='date')",例如:
<input required="" type="text" class="form-control" placeholder="Date" onfocus="(this.type='date')"/>
Run Code Online (Sandbox Code Playgroud)
小智 8
使用onfocus和onblur ......这是一个例子:
<input type="text" placeholder="Birth Date" onfocus="(this.type='date')" onblur="if(this.value==''){this.type='text'}">
Run Code Online (Sandbox Code Playgroud)
在这里,我尝试data了input元素中的属性。并使用 CSS 应用所需的占位符
<input type="date" name="dob" data-placeholder="Date of birth" required aria-required="true" />
Run Code Online (Sandbox Code Playgroud)
<input type="date" name="dob" data-placeholder="Date of birth" required aria-required="true" />
Run Code Online (Sandbox Code Playgroud)
input[type="date"]::before {
content: attr(data-placeholder);
width: 100%;
}
/* hide our custom/fake placeholder text when in focus to show the default
* 'mm/dd/yyyy' value and when valid to show the users' date of birth value.
*/
input[type="date"]:focus::before,
input[type="date"]:valid::before { display: none }Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
小智 5
<input type="text" placeholder="*To Date" onfocus="(this.type='date')" onblur="(this.type='text')" >
Run Code Online (Sandbox Code Playgroud)
这段代码对我有用。只需你可以使用这个
| 归档时间: |
|
| 查看次数: |
29993 次 |
| 最近记录: |