当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 最精致的日历式日期输入控件

HTML/XHTML教程
IE5+专有日历
跨框架下拉菜单
用鼠标拖动表格进行排序
通用表单验证函数
静态页面的值传递(三部曲)
用javascript获得地址栏参数的两种方法
校验日期的函数
Select的OnChange()事件
区分只读文本框和普通文本框的背景色
指定选取textarea的特定行
清除WORD冗余格式并粘贴
页面载入时提示消息层
正则表达式regular expression详述
最精致的日历式日期输入控件
MD5算法在JS中的实现
javascript 的面向对象编程
自适应图片大小的弹出窗口
锁定行头和列头的表格组件
简化的enter转化成tab组件
日期相加的函数addDate

HTML/XHTML教程 中的 最精致的日历式日期输入控件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 31 ::
收藏到网摘: n/a

<HTML>
<HEAD>
<TITLE>最精致的日历式日期输入控件 (Smart Ver 1.00)</TITLE>
</HEAD>
<style>
body
{
 font-size:12px;
 font-family:"Tahoma";
}
td
{
 font-size:12px;
 font-family:"Tahoma";
}
.inputdate
{
 border:1px solid #7287c6;
 text-align: center;
 font-size: 12px;
 font-style: normal;
 height: 16px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
/********************************************************************
more javascript from http://www.smallrain.net
时间:2004-01-01
作者:Smart
功能:日历式日期选择控件
 
参数:
说明:
1.输入框直接调用用以下代码
<Script>DateBox("InputName","DateValue")<\/Script>
其中:InputName 为输入日期的文本框.注:不能为空.
       DateValue  为输入日期的文本框默认日期值.格式为:YYYY-MM-DD.如2004-01-01
                       此值可以不填或为空.则默认值为当天日期.(客户端)
2.其它"按钮"调用用以下代码
CallDate("InputName")
其中:InputName 为输入日期的文本框.注:不能为空.
修改区
时间:
修改人:
原因:
********************************************************************/
/*基本参数*/
var Frw=106; //日历宽度
var Frh=137; //日历高度
var Frs=4;     //影子大小
var Hid=true;//日历是否打开
/*创建框架*/
document.writeln('<Div id=Calendar Author=smart  scrolling="no" frameborder=0 style="border:0px solid #EEEEEE ;position: absolute; width: '+Frw+'; height: '+Frh+'; z-index: 0; filter :\'progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#AAAAAA,strength='+Frs+')\' ;display: none"></Div>');
/*取得今日日期*/
function GetTodayDate()
{
   today= new Date();
   y= today.getYear();
   m= (today.getMonth() + 1);
   if (m<10)
   {
     m='0'+m;
   }
   d= today.getDate();
   if (d<10)
   {
     d='0'+d;
   }
return y+'-'+m+'-'+d
}
/*输入今天日期*/
function SetTodayDate(InputBox)
{
  HiddenCalendar();
  InputBox.value=GetTodayDate();
}
/*取某年某月第一天的星期值(月份-1)*/
function GetFirstWeek(The_Year,The_Month)
{
  return (new Date(The_Year,The_Month-1,1)).getDay()
}
/*取某年某月中总天数*/
function GetThisDays(The_Year,The_Month)
{
  return (new Date(The_Year,The_Month,0)).getDate()
}
/*取某年某月上个月中总天数*/
function GetLastDays(The_Year,The_Month)
{
  return (new Date(The_Year,The_Month-1,0)).getDate()
}
/*判断是否是闰年*/
function RunNian(The_Year)
{
 if ((The_Year%400==0) || ((The_Year%4==0) && (The_Year%100!=0)))
  return true;
 else
  return false;
}
/* 判断日期(YYYY-MM-DD)的日期是否正确 */
function DateIsTrue(asDate){
 var lsDate  = asDate + "";
 var loDate  = lsDate.split("-");
 if (loDate.length!=3) return false;
 var liYear  = parseFloat(loDate[0]);
 var liMonth = parseFloat(loDate);
 var liDay   = parseFloat(loDate);
 if ((loDate[0].length>4)||(loDate.length>2)||(loDate.length>2)) return false;
 if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay)) return false;
 if ((liYear<1800)||(liYear>2500)) return false;
 if ((liMonth>12)||(liMonth<=0))   return false;
 if (GetThisDays(liYear,liMonth)<liDay) return false;
 return !isNaN(Date.UTC(liYear,liMonth,liDay));
}
/*取某年某月的周值*/
function GetCountWeeks(The_Year,The_Month)
{
 var Allday;
 Allday = 0;
 if (The_Year>2000)
 {
&nbs