1.UCCalendar.ascx
<%@ control Language="vb" AutoEventWireup="false" Codebehind="UCCalendar.aspx.vb" Inherits="WebApplication1.UCCalendar"%>
<FONT face="新細明體">
<script language="javascript">
function CheckDate(o){
var Str=new String;
var StrEnd = new String;
Str = o.value;
if (Str != "" )
{
if (chkformat(Str) == false)
{
o.focus();
}
}
}
function chkformat(datestr)
{
var lthdatestr
lthdatestr= datestr.length ;
var tmpy="";
var tmpm="";
var tmpd="";
//var datestr;
var status;
status=0;
for (i=0;i<lthdatestr;i++){
if (datestr.charAt(i)== '/'){
status++;
}
if (status>2){
alert("日期錯誤");
return false;
}
if ((status==0) && (datestr.charAt(i)!='/')){
tmpy=tmpy+datestr.charAt(i)
}
if ((status==1) && (datestr.charAt(i)!='/')){
tmpm=tmpm+datestr.charAt(i)
}
if ((status==2) && (datestr.charAt(i)!='/')){
tmpd=tmpd+datestr.charAt(i)
}
}
year=new String (tmpy);
month=new String (tmpm);
day=new String (tmpd)
//tempdate= new String (year+month+day);
//alert(tempdate);
if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
{
alert("日期錯誤");
// alert("date");
return false;
}
if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
{
alert ("日期錯誤");
return false;
}
if (!((year % 4)==0) && (month==2) && (day==29))
{
alert ("日期錯誤");
return false;
}
if ((month<=7) && ((month % 2)==0) && (day>=31))
{
alert ("日期錯誤");
return false;
}
if ((month>=8) && ((month % 2)==1) && (day>=31))
{
alert ("日期錯誤");
return false;
}
if ((month==2) && (day==30))
{
alert("日期錯誤");
return false;
}
return true;
}
</script>
<div align="center"><asp:textbox id="txtCalendar" onblur="CheckDate(this)" runat="server" Width="181px"></asp:textbox><asp:button id="btnCandelar" runat="server" Text="...."></asp:button><asp:calendar id="Calendar1" runat="server" Width="208px" Height="200px" BorderWidth="1px" BackColor="White"
ForeColor="#003399" Font-Size="8pt" Font-Names="Verdana" BorderColor="#3366CC" CellPadding="1" ShowGridLines="True">
<TodayDayStyle ForeColor="White" BackColor="#99CCCC"></TodayDayStyle>
<SelectorStyle ForeColor="#336666" BackColor="#99CCCC"></SelectorStyle>
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle>
<DayHeaderStyle Height="1px" ForeColor="#336666" BackColor="#99CCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedDayStyle>
<TitleStyle Font-Size="10pt" Font-Bold="True" Height="25px" BorderWidth="1px" ForeColor="#CCCCFF"
BorderStyle="Solid" BorderColor="#3366CC" BackColor="#003399"></TitleStyle>
<WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar></div>
</FONT>
2.UCCale