placeholder for input type date html5

前端 未结 5 1039
臣服心动
臣服心动 2020-12-19 10:38

placeholder does not work for input type date directly.


5条回答
  •  执念已碎
    2020-12-19 11:05

    Here, I have tried data attribute in input element. and applied required placeholder using CSS

    
    

        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 }

    Hope this helps

提交回复
热议问题