Is there any way to change input type=“date” format?

前端 未结 15 1801
清酒与你
清酒与你 2020-11-21 04:17

I\'m working with HTML5 elements on my webpage. By default input type=\"date\" shows date as YYYY-MM-DD.

The question is, is it possible t

15条回答
  •  面向向阳花
    2020-11-21 05:05

    Try this if you need a quick solution To make yyyy-mm-dd go "dd- Sep -2016"

    1) Create near your input one span class (act as label)

    2) Update the label everytime your date is changed by user, or when need to load from data.

    Works for webkit browser mobiles and pointer-events for IE11+ requires jQuery and Jquery Date

    $("#date_input").on("change", function () {
         $(this).css("color", "rgba(0,0,0,0)").siblings(".datepicker_label").css({ "text-align":"center", position: "absolute",left: "10px", top:"14px",width:$(this).width()}).text($(this).val().length == 0 ? "" : ($.datepicker.formatDate($(this).attr("dateformat"), new Date($(this).val()))));
            });
    #date_input{text-indent: -500px;height:25px; width:200px;}
    
    
    
    

提交回复
热议问题