如何让一个text输入框的默认日期是今天,我只想在html里面实现!

rt
---------------------------------------------------------------

1<form name="form1">
2<input name="test" type="text"/>
3</form>
1<script language="JavaScript">   
2today=new Date();   
3form1.test.value=today.getYear()+'年'+today.getMonth()+'月'+today.getDay()+'日';   
4</script>

---------------------------------------------------------------

1<input id="myDate" type="text"/>
1<script language="JavaScript">   
2<!--   
3var now = new Date();   
4myDate.value=now.getYear() + "-"+ (now.getMonth()+1)+"-"+now.getDate();   
5//-->   
6</script>

---------------------------------------------------------------

 1<script language="JavaScript"><!--   
 2function time_rota() //写当前日期的函数   
 3{   
 4var now = new Date();   
 5var h = now.getFullYear();   
 6var m = (now.getMonth() + 1>9) ? now.getMonth() + 1 : "0"+(now.getMonth() + 1);   
 7var s = (now.getDate()>9) ? now.getDate() : "0"+now.getDate();   
 8document.form1.Today.value = h+"年"+m+"月"+s+"日";   
 9}   
10//--></script>
1<body onload="time_rota()">
2<form name="form1">
3<input name="Today"/>
4</form></body>
Published At
Categories with Web编程
comments powered by Disqus