官网:http://jonathanleighton.com/projects/date-input/
下载:
http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js
http://github.com/jonleighton/date_input/raw/master/jquery.date_input.js
http://github.com/jonleighton/date_input/raw/master/date_input.css
插件下载:http://download.csdn.net/detail/cometwo/9052329
中文支持:
- jQuery.extend(DateInput.DEFAULT_OPTS, { month_names: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], short_month_names: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"], short_day_names: ["一", "二", "三", "四", "五", "六", "日"]});
说明:默认是日期格式很不好,需要修改。
全部代码:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>日历</title>
- <script type="text/javascript" src="jquery-1.3.2.js"></script>
- <script type="text/javascript" src="jquery.date_input.js"></script>
- <link rel="stylesheet" href="date_input.css" type="text/css">
- <script>
- jQuery.extend(DateInput.DEFAULT_OPTS, {
- month_names: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- short_month_names: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
- short_day_names: ["一", "二", "三", "四", "五", "六", "日"],
- dateToString: function(date) {
- var month = (date.getMonth() + 1).toString();
- var dom = date.getDate().toString();
- if (month.length == 1) month = "0" + month;
- if (dom.length == 1) dom = "0" + dom;
- return date.getFullYear() + "-" + month + "-" + dom;
- }
- });
- $(function() {
- $(".biuuu1").date_input();
- $(".biuuu2").date_input();
- });
- </script>
- </head>
- <body>
- <input type="text" class="biuuu1" name="date"/>
- <input type="text" class="biuuu2" name="date"/>
- </body>
- </html>
http://
原文:点击打开链接
http://blog.csdn.net/sujudz/article/details/8120222
jquery的date input日期选择控件,在一些日期表单上使用,效果还是比较好的。
官方介绍和下载地址 http://jonathanleighton.com/projects/date-input/
使用前需要导入jquery库和date input的库和css文件
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/jquery.date_input.js"></script>
<link rel="stylesheet" href="css/date_input.css" type="text/css">
官网下载的包里就包含了js和css文件。
使用前先改变默认的日期格式,下面是中文日期。参数设置都很简单,就是最后的dateToString参数值是返回的日期格式,这里是 年-月-日 的格式。可以自己更改。
[javascript] view
plaincopy
- $.extend(DateInput.DEFAULT_OPTS, { month_names: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- short_month_names: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
- short_day_names: ["日","一", "二", "三", "四", "五", "六"],
- dateToString: function(date) {
- var month = (date.getMonth() + 1).toString();//月份
- var dom = date.getDate().toString();//日
- if (month.length == 1) month = "0" + month;//控制月份为10一下的显示为01格式
- if (dom.length == 1) dom = "0" + dom;//同月份
- return date.getFullYear() + "-" + month + "-" + dom;
- }
- }
- );
*在下载的压缩包里,有个translations目录,里面有默认语言的日期设置,jquery.date_input.zh_CN.js就是中文日期,不过他的short_day_names参数是["一", "二", "三", "四", "五", "六","日"]。星期日和一显示不对。
响应inpu组件代码
$(function(){$("#birthday").date_input();});
birthday是组件ID
<input readonly id="birthday" type="text" name="birthday" size="20">