1var today = new Date();
2var dd = today.getDate();
3var mm = today.getMonth()+1; //January is 0!
4var yyyy = today.getFullYear();
5 if(dd<10){
6 dd='0'+dd
7 }
8 if(mm<10){
9 mm='0'+mm
10 }
11
12today = yyyy+'-'+mm+'-'+dd;
13document.getElementById("datefield").setAttribute("max", today);
14