默认日期为3/23/2011 改为2010-03-23等
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery EasyUI</title>
<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../themes/icon.css">
<script type="text/javascript" src="../jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../jquery.easyui.min.js"></script>
<script>
$('#dd').datebox({
closeText:'关闭',
formatter:function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
var h = date.getHours();
var M = date.getMinutes();
var s = date.getSeconds();
function formatNumber(value){
return (value < 10 ? '0' : '') + value;
}
alert(formatNumber(h));
return y+'-'+m+'-'+d+' '+ formatNumber(h)+':'+formatNumber(M)+':'+formatNumber(s);
},
parser:function(s){
var t = Date.parse(s);
if (!isNaN(t)){
return new Date(t);
} else {
return new Date();
}
}
});
</script>
</head>
<body>
<h1>DateBox</h1>
<div style="margin-bottom:10px;">
<a href="#" οnclick="disable()">disable</a>
<a href="#" οnclick="enable()">enable</a>
</div>
<input id="dd" class="easyui-datetimebox" value="3/23/2010 23:10:10" required="true"></input>
</body>
</html>
datebox有以下属性
currentText 看名字就知道意思了即当前按钮显示的文本内容 默认为today
closeText 关闭按钮显示的文本内容 默认是close
disabled 插件是否有用
formatter 即文本框中日期显示的格式,改属性是一个函数,解释一个date的参数
parser 看名知意解析日期字符串成日期类型
Name | Type | Description | Default |
---|---|---|---|
currentText | string | The text to display for the current day button. | Today |
closeText | string | The text to display for the close button. | Close |
disabled | boolean | When true to disable the field. | false |
formatter | function | A function to format the date, the function take a 'date' parameter and return a string value. | |
parser | function | A function to parse a date string, the function take a 'date' string and return a date value. |