HTML-5 date field shows as “mm/dd/yyyy” in Chrome, even when valid date is set

前端 未结 5 1233
慢半拍i
慢半拍i 2020-12-29 00:55

I just upgraded an ASP.Net MVC application to MVC-4. The field editor for inputs based on DateTime values now include\'s the HTML-5 type="date" attrib

5条回答
  •  灰色年华
    2020-12-29 02:01

    I have same problem and i found solution which is given below with full datepicker using simple HTML,Javascript and CSS. In this code i prepare formate like dd/mm/yyyy but you can work any.

    HTML Code:

        
    
    
    
    
    

    CSS Code:

    #dt{text-indent: -500px;height:25px; width:200px;}
    

    Javascript Code :

    function mydate()
    {
      //alert("");
    document.getElementById("dt").hidden=false;
    document.getElementById("ndt").hidden=true;
    }
    function mydate1()
    {
     d=new Date(document.getElementById("dt").value);
    dt=d.getDate();
    mn=d.getMonth();
    mn++;
    yy=d.getFullYear();
    document.getElementById("ndt").value=dt+"/"+mn+"/"+yy
    document.getElementById("ndt").hidden=false;
    document.getElementById("dt").hidden=true;
    }
    

    Output:

提交回复
热议问题