채택완료

input type="date"일 때, placeholder를 text로 설정하는 방법

안녕하세요. 

 

        <label for="wr_name" class="sound_only">주문 날짜<strong>필수</strong></label>
        <input type="date" name="wr_name" value="<?php echo $name ?>" id="wr_name" required aria-required="true" class="frm_input required" placeholder="주문 날짜">

 

 

input type은 date로 설정하고, 날짜 선택 전에 보이는 칸에는 텍스트가 보여지게 하고 싶습니다.

인터넷에 검색해봐도 적절한 방법을 찾지 못해 문의드립니다.

 

input type="date"일 때, placeholder를 text로 설정하는 방법이 있을까요?

|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트
input[type="date"]:not(.has-value):before{
  color: lightgray;
  content: attr(placeholder);
}
<input type="date" placeholder="MY PLACEHOLDER" onchange="this.className=(this.value!=''?'has-value':'')">

답변에 대한 댓글 1개

답변을 작성하려면 로그인이 필요합니다.