在html中让一个text输入框的默认日期是今天
2012-01-10 10:31
155 查看
方法一:
<form name="form1">
<input type="text" name="test">
</form>
<script language="JavaScript">
today=new Date();
form1.test.value=today.getYear()+'年'+today.getMonth()+'月'+today.getDay()+'日';
</script>
<br>
方法二:
---------------------------------------------------------------
<br>
<INPUT TYPE="text" id="myDate">
<SCRIPT LANGUAGE="JavaScript">
<!--
var now = new Date();
myDate.value=now.getYear() + "-"+ (now.getMonth()+1)+"-"+now.getDate();
//-->
</SCRIPT>
<br>
方法三:
---------------------------------------------------------------
<br>
<script language="JavaScript"><!--
function time_rota() //写当前日期的函数
{
var now = new Date();
var h = now.getFullYear();
var m = (now.getMonth() + 1>9) ? now.getMonth() + 1 : "0"+(now.getMonth() + 1);
var s = (now.getDate()>9) ? now.getDate() : "0"+now.getDate();
document.form1.Today.value = h+"年"+m+"月"+s+"日";
}
//--></script>
<body onload="time_rota()">
<form name=form1>
<input name=Today>
</form>
<form name="form1">
<input type="text" name="test">
</form>
<script language="JavaScript">
today=new Date();
form1.test.value=today.getYear()+'年'+today.getMonth()+'月'+today.getDay()+'日';
</script>
<br>
方法二:
---------------------------------------------------------------
<br>
<INPUT TYPE="text" id="myDate">
<SCRIPT LANGUAGE="JavaScript">
<!--
var now = new Date();
myDate.value=now.getYear() + "-"+ (now.getMonth()+1)+"-"+now.getDate();
//-->
</SCRIPT>
<br>
方法三:
---------------------------------------------------------------
<br>
<script language="JavaScript"><!--
function time_rota() //写当前日期的函数
{
var now = new Date();
var h = now.getFullYear();
var m = (now.getMonth() + 1>9) ? now.getMonth() + 1 : "0"+(now.getMonth() + 1);
var s = (now.getDate()>9) ? now.getDate() : "0"+now.getDate();
document.form1.Today.value = h+"年"+m+"月"+s+"日";
}
//--></script>
<body onload="time_rota()">
<form name=form1>
<input name=Today>
</form>
相关文章推荐
- 在html中让一个text输入框的默认日期是今天
- 今天遇到一个问题,原来在html的form中如果只有一个type="text"的控件,如果在text中点击回车键,就是自动提交表单!
- HTML 之 Web页面表单form中只有一个input的text元素,按回车默认提交
- tableau中创建一个默认为今天日期的日期字段
- Java 判断一个日期 是否为 今天、昨天
- 判断一个日期距离今天是不是过了指定的天数
- 记一次EditText设置默认选中setSelection的一个bug
- HTML里的一个TD里面的TEXTBOX对齐(TEXTBOX与TEXT的对齐问题)
- JS写一个函数输出今天的日期
- HTML中Input输入框的只能输入数字,限制长度,默认显示文字等
- js中创建html标签、添加select下默认的option的value和text、删除select元素节点下所有的OPTION节点
- Android TextView与html的结合使用 一个控件显示多种文字
- 让html中的输入框(<input type="text"...)变成灰色且不能修改其中的值
- html基础 下拉选择框 一个,默认选中
- 一个textview多种颜色,或试用html多种颜色
- SDTextField:一个可以诱导输入的输入框
- 今天试了一下ajax dropdownlist联动,实际上是先写在一个XmlTextWriter(Response.OutputStream,然后再response回去(等同于一个XML),里面有很多要注意的地方,比如dropdownlist的清空,遍历X
- 今天再分享一个TextView内容风格化的类
- html基础 下拉选择框 一个,默认选中
- 今天是2011年三月19号,一个难忘的日期。