国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET中為TextBox中添加calendar.js示例代碼

2024-07-10 12:44:24
字體:
供稿:網(wǎng)友
1.在工程文件下面新建文件夾"js",然后向其中添加JavaScript.js新建項(xiàng),重命名為calendar.js。

2.向calendar.js中寫入代碼,
代碼如下:
var cal;
var isFocus=false; //是否為焦點(diǎn)
//function SelectDate(obj,strFormat) //兩個(gè)參數(shù)改為只傳一個(gè)
function SelectDate(obj)
{
var date = new Date();
var by = date.getFullYear()-80; //最小值 → 80 年前
var ey = date.getFullYear()+20; //最大值 → 20 年后
cal = (cal==null) ? new Calendar(by, ey, 0) : cal; //初始化為中文版,1為英文版
//cal.dateFormatStyle = strFormat; // 默認(rèn)顯示格式為:yyyy-MM-dd ,還可顯示 yyyy/MM/dd
cal.show(obj);
}
/**//* 返回日期 */
String.prototype.toDate = function(style){
var y = this.substring(style.indexOf('y'),style.lastIndexOf('y')+1);//年
var m = this.substring(style.indexOf('M'),style.lastIndexOf('M')+1);//月
var d = this.substring(style.indexOf('d'),style.lastIndexOf('d')+1);//日
if(isNaN(y)) y = new Date().getFullYear();
if(isNaN(m)) m = new Date().getMonth();
if(isNaN(d)) d = new Date().getDate();
var dt ;
eval ("dt = new Date('"+ y+"', '"+(m-1)+"','"+ d +"')");
return dt;
}
/**//* 格式化日期 */
Date.prototype.format = function(style){
var o = {
"M+" : this.getMonth() + 1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"w+" : "天一二三四五六".charAt(this.getDay()), //week
"q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(style)){
style = style.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for(var k in o){
if(new RegExp("("+ k +")").test(style)){
style = style.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
}
}
return style;
};

/**//*
* 日歷類
* @param beginYear 2009
* @param endYear 2015
* @param lang 0(中文)|1(英語) 可自由擴(kuò)充
* @param dateFormatStyle "yyyy-MM-dd";
*/
function Calendar(beginYear, endYear, lang, dateFormatStyle){
this.beginYear = 2009;
this.endYear = 2015;
this.lang = 0; //0(中文) | 1(英文)
this.dateFormatStyle = "yyyy-MM-dd";

if (beginYear != null && endYear != null){
this.beginYear = beginYear;
this.endYear = endYear;
}
if (lang != null){
this.lang = lang
}

if (dateFormatStyle != null){
this.dateFormatStyle = dateFormatStyle
}

this.dateControl = null;
this.panel = this.getElementById("calendarPanel");
this.container = this.getElementById("ContainerPanel");
this.form = null;

this.date = new Date();
this.year = this.date.getFullYear();
this.month = this.date.getMonth();


this.colors = {
"cur_word" : "#FFFFFF", //當(dāng)日日期文字顏色
"cur_bg" : "#83A6F4", //當(dāng)日日期單元格背影色
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 梅州市| 双城市| 滨州市| 仪陇县| 修水县| 元江| 砚山县| 白城市| 西平县| 嵩明县| 龙泉市| 原平市| 锡林浩特市| 扎兰屯市| 平和县| 建宁县| 翁源县| 齐河县| 明水县| 汉源县| 郯城县| 宜州市| 教育| 西充县| 博湖县| 翼城县| 新疆| 外汇| 读书| 聊城市| 安阳县| 海口市| 青岛市| 浠水县| 英德市| 宁武县| 东莞市| 黄陵县| 故城县| 库尔勒市| 长兴县|