Setting format and value in input type=“date”

后端 未结 12 1587
暖寄归人
暖寄归人 2020-12-06 17:05

Is there any way to set the format of ? if no then how can i set date in this field using JavaScript in the default format of

12条回答
  •  旧时难觅i
    2020-12-06 17:11

    I think this can help

    function myFormatDateFunction(date, format) {
         ...
    }
    
    jQuery('input[type="date"]')                                             
        .each(function(){                                                              
            Object.defineProperty(this,'value',{                                         
              get: function() {                                   
                return myFormatDateFunction(this.valueAsDate, 'dd.mm.yyyy');      
              },                                                                         
              configurable: true,                                                        
              enumerable : true                                                          
            });                                                                          
          });                                                                                
    

提交回复
热议问题