TypeError: Date is not a constructor

前端 未结 4 904
逝去的感伤
逝去的感伤 2021-01-17 16:05

So, I\'ve been making forms for my company for some time now with pretty easy Javascript that has worked for me in the past. However all of a sudden it\'s kicking out the er

4条回答
  •  不要未来只要你来
    2021-01-17 16:32

    I was having this problem and I solved it! don't use "Date" as variable because this causes conflict with Global function Date();

    Exemple: Wrong !

    var Date = new Date();
         document.getElementById('dateCopy').innerHTML = Date.getFullYear();
    

    Right:

    var DateTime = new Date();
          document.getElementById('dateCopy').innerHTML = DateTime.getFullYear();
    

    In your case:

    var DateTime = this.getField("Text1");
    DateTime.value = util.printd("mm/dd/yyyy",new Date());
    

提交回复
热议问题