JS determines the correctness of the input date (there are two functions, very similar)
---------------------------
JS determines the correctness of the input date
<script language=javascript>
function strDateTime(str){
var reg = /^(\d{1,4})(-\/)(\d{1,2})\2(\d{1,2})$/;
var r = (reg);
if(r==null)return false;
var d= new Date(r[1], r[3]-1,r[4]);
var newStr=()+r[2]+(()+1)+r[2]+()
return newStr==str
}
alert(strDateTime("2002-1-31"))
alert(strDateTime("2002-1-41"))
</script>
<script language=javascript>
function strDateTime(str){
var reg = /^(\d{1,4})(-\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
var r = (reg);
if(r==null)return false;
var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
var newStr=()+r[2]+(()+1)+r[2]+()+" "+()+":"+()+":"+()
return newStr==str
}
alert(strDateTime("2002-1-31 12:34:56"))
alert(strDateTime("2001-2-29 12:54:56"))
alert(strDateTime("2002-1-41 12:00:00"))
</script>
<script language="javascript">
var s="2002-4-16"
alert(chkDate(s));
function chkDate(sDate){
var r=/\d{4}(?:-\d{1,2}){0,2}/
// Regular expression, determine whether it is in yyyy-mm-dd,yyyy-mm,yyyyy format
if((r)==sDate){
var arr=("-")
switch(){
//Judge whether the year, month, day and number are correct according to different yyyy-mm-dd, yyyy-mm formats
case 3:
var tmpDate=new Date(arr[0],arr[1],arr[2]);
if(()==arr[1] && ()==arr[0]) return true;
break;
case 2:
if(arr[1]<13) return true;
break;
default:
return false;
}
}
return false;
}
</script>
/*
Time validity judgment function
All by happywinds
*/
function verifyDate(textObj) {
var str=;
= (/\s+/g,"");
if((/^\d{4}-\d{1,2}-\d{1,2}$/) == 0){
var y = parseInt(("-")[0]);
var m = parseInt(("-")[1]);
var d = parseInt(("-")[2]);
switch(m){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if(d>31){
return false;
();
();
}else{
return true;
}
break;
case 2:
if((y%4==0 && d>29) ((y%4!=0 && d>28))){
return false;
();
();
}else{
return true;
}
break;
case 4:
case 6:
case 9:
case 11:
if(d>30){
return false;
();
();
}else{
return true;
}
break;
default:
return false;
();
();
}
}else{
return false;
();
();
}
}
meizz (Plum Blossom Rain) Javascript script calendar input control for spotted bamboo (Haha, I borrowed flowers to offer Buddha)
----------------------------------------------
Called code:
<script language=javascript src=../../></script>
<input onfocus="setday(this)">
or
<script language=javascript src=../../></script>
<input name=txt><input type=button value=setday onclick="setday(this,)">
Control code:
<!--
//-------------------------------------------------------------------------------
// This is a calendar Javascript page script control I made, suitable for Microsoft's IE (5.0 or above) browser
// The main call function is setday(this,[object]), [object] is the control name output by the control. Give two specific calls:
// 1. <input name=txt><input type=button value=setday onclick="setday(this,)">
// 2. <input onfocus="setday(this)">
// If you have any shortcomings, or if you have any better suggestions, please contact me: mail: meizz@
// The year limit for this calendar is (1000 - 9999)
//=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
('<div id=meizzDateLayer style="position: absolute; width: 142; height: 166; z-index: 9998; display: none">');
('<span id=tmpSelectYearLayer style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
('<table border=0 cellspacing=1 cellpadding=0 width=142 height=160 bgcolor=#808080 onselectstart="return false">');
(' <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 height=23>');
(' <tr align=center><td width=20 align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
(' onclick="meizzPrevM()" title="Flip forward" Author=meizz><b Author=meizz><<</b>');
(' </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');
(' <span Author=meizz id=meizzYearHead onclick="tmpSelectYearInnerHTML()"></span> year <span');
(' id=meizzMonthHead Author=meizz onclick="tmpSelectMonthInnerHTML()"></span> month</td>');
(' <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
(' onclick="meizzNextM()" title="Flip back the moon" Author=meizz><b Author=meizz>>></b></td></tr>');
(' </table></td></tr>');
(' <tr><td width=142 height=18 bgcolor=#808080>');
('<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">');
('<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=meizz>day</td>');
('<td style="font-size:12px;color:#FFFFFF" Author=meizz>1</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>2</td>');
('<td style="font-size:12px;color:#FFFFFF" Author=meizz>three</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>four</td>');
('<td style="font-size:12px;color:#FFFFFF" Author=meizz>five</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>six</td></tr>');
('</table></td></tr><!-- Author:(meizz) / mail: meizz@ 2002-10-8 -->');
(' <tr><td width=142 height=120>');
(' <table border=0 cellspacing=1 cellpadding=0 width=140 height=120 bgcolor=#FFFFFF>');
var n=0; for (j=0;j<5;j++){ (' <tr align=center>'); for (i=0;i<7;i++){
('<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=meizzDayClick()></td>');n++;}
('</tr>');}
(' <tr align=center><td width=20 height=20 style="font-size:12px" id=meizzDay35 Author=meizz ');
(' onclick=meizzDayClick()></td>');
(' <td width=20 height=20 style="font-size:12px" id=meizzDay36 Author=meizz onclick=meizzDayClick()></td>');
(' <td colspan=5 align=right Author=meizz><span onclick=closeLayer() style="font-size:12px;cursor: hand"');
(' Author=meizz title="Author: (meizz) MAIL: meizz@"><u>Close this control</u></span> </td></tr>');
(' </table></td></tr><tr><td>');
(' <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
(' <tr><td Author=meizz align=left><input Author=meizz type=button value="< " title="Flip forward year" onclick="meizzPrevY()" ');
(' onfocus="()" style="font-size: 12px; height: 20px"><input Author=meizz title="Flip forward month" type=button ');
(' value="<<" onclick="meizzPrevM()" onfocus="()" style="font-size: 12px; height: 20px"></td><td ');
(' Author=meizz align=center><input Author=meizz type=button value=Today onclick="meizzToday()" ');
(' onfocus="()" title="now year and month" style="font-size: 12px; height: 20px"></td><td ');
(' Author=meizz align=right><input Author=meizz type=button value=">>" onclick="meizzNextM()" ');
(' onfocus="()" title="Flip back the moon" style="font-size: 12px; height: 20px"><input ');
(' Author=meizz type=button value=" >" title="Flip back year" onclick="meizzNextY()"');
(' onfocus="()" style="font-size: 12px; height: 20px"></td>');
('</tr></table></td></tr></table></div>');
meizz (Plum Blossom Rain) Javascript script calendar input control for spotted bamboo (II)
-------------------------------------------------------
//=============================================================================================================================================================================================================================================================
var outObject;
function setday(tt,obj) //main call function
{
if ( > 2){alert("Sorry! There are too many parameters passed into this control!");return;}
if ( == 0){alert("Sorry! You did not pass any parameters back to this control!");return;}
var dads = ;var th = tt;
var ttop = ; //The positioning point of the TT control is high
var thei = ; //The height of the TT control itself
var tleft = ; //The positioning point width of the TT control
var ttyp = ; //TT control type
while (tt = ){ttop+=; tleft+=;}
= (ttyp=="image")? ttop+thei : ttop+thei+6;
= tleft;
outObject = ( == 1) ? th : obj;
= '';
=false;
}
var MonHead = new Array(12); //Define the maximum number of days per month in the Gregorian calendar
MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30;
MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;
var meizzTheYear=new Date().getFullYear(); //Define the initial value of the variable of the year
var meizzTheMonth=new Date().getMonth()+1; //Define the initial value of the variable for the month
var meizzWDay=new Array(37); //Define an array of write dates
function () //Close the control when clicking any time
{
with()
{ if (tagName != "INPUT" && getAttribute("Author")==null)
="none";
}
}
function meizzWriteHead(yy,mm) //Write the current year and month into the head
{ = yy;
= mm;
}
function tmpSelectYearInnerHTML(strYear) // drop-down box for year
{
if ((/\D/)!=null){alert("The input parameter of the year is not a number!");return;}
var m = (strYear) ? strYear : new Date().getFullYear();
if (m < 1000 m > 9999) {alert("Year value is not between 1000 and 9999!");return;}
var n = m - 10;
if (n < 1000) n = 1000;
if (n + 26 > 9999) n = 9974;
var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
s += "onblur='=\"none\"' "
s += "onchange='=\"none\";"
s += "meizzTheYear = ; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
var selectInnerHTML = s;
for (var i = n; i < n + 26; i++)
{
if (i == m)
{selectInnerHTML += "<option value='" + i + "' selected>" + i + "year" + "</option>\r\n";}
else {selectInnerHTML += "<option value='" + i + "'>" + i + "year" + "</option>\r\n";}
}
selectInnerHTML += "</select>";
="";
= selectInnerHTML;
();
}
function tmpSelectMonthInnerHTML(strMonth) // pull down box for month
{
if ((/\D/)!=null){alert("The input parameter for the month is not a number!");return;}
var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
var s = "<select Author=meizz name=tmpSelectMonth style='font-size: 12px' "
s += "onblur='=\"none\"' "
s += "onchange='=\"none\";"
s += "meizzTheMonth = ; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
var selectInnerHTML = s;
for (var i = 1; i < 13; i++)
{
if (i == m)
{selectInnerHTML += "<option value='"+i+"' selected>"+i+"month"+"</option>\r\n";}
else {selectInnerHTML += "<option value='"+i+"'>"+i+"month"+"</option>\r\n";}
}
selectInnerHTML += "</select>";
="";
= selectInnerHTML;
();
}
function closeLayer() // Close of this layer
{
="none";
}
function ()
{
if (==27)="none";
}
function IsPinYear(year) //Judge whether it is a leap year
{
if (0==year%4&&((year%100!=0)(year%400==0))) return true;else return false;
}
function GetMonthCount(year, month) // February of leap year is 29 days
{
var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
}
function GetDOW(day, month, year) //Check the day of the week of a certain day
{
var dt=new Date(year,month-1,day).getDay()/7; return dt;
}
function meizzPrevY() //Flip forward Year
{
if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
else{alert("Year out of range (1000-9999)!");}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzNextY() //Flip back Year
{
if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
else{alert("Year out of range (1000-9999)!");}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzToday() //Today Button
{
meizzTheYear = new Date().getFullYear();
meizzTheMonth = new Date().getMonth()+1;
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzPrevM() //Follow the month ahead
{
if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzNextM() //Follow the month
{
if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzSetDay(yy,mm) //Main writing program**********
{
meizzWriteHead(yy,mm);
for (var i = 0; i < 37; i++){meizzWDay[i]=""}; //Clear all contents of the display box
var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); //What day of the week of the first day of a certain month
for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
for (var i = 0; i < 37; i++)
{ var da = eval(""+i) //Writing the date and week arrangement of the new month
if (meizzWDay[i]!="")
{ = "<b>" + meizzWDay[i] + "</b>";
= (yy == new Date().getFullYear() &&
mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
="hand"
}
else{="";="";="default"}
}
}
function meizzDayClick(n) //Click the display box to select the date, the main input function ****************
{
var yy = meizzTheYear;
var mm = meizzTheMonth;
if (mm < 10){mm = "0" + mm;}
if (outObject)
{
if (!n) {=""; return;}
if ( n < 10){n = "0" + n;}
= yy + "" + mm + "" + n ; //Note: Here you can change the output to the format you want
closeLayer();
}
else {closeLayer(); alert("The control object you want to output does not exist!");}
}
meizzSetDay(meizzTheYear,meizzTheMonth);
// -->
Web progress bar
----------------------------------
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
var myTime=0
function counter(){
myTime++
="<font size=2 color=darkblue> "+myTime+"%</font>"
if (myTime<100)
setTimeout("counter()",40);
else{
("",null,"fullscreen=yes,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no")
}
}
function window_onload() {
counter()
}
//-->
</SCRIPT>
</HEAD>
<BODY LANGUAGE=javascript onload="return window_onload()">
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<table border="0" cellpadding="0" cellspacing="0" width="50%" align=center>
<tr>
<td width="51%" noWrap>
<p align="right"><FONT face=Ancient and peaceful peaceful and peaceful peaceful and peaceful peaceful and peaceful peaceful and peaceful peaceful�
size=2>Loading:</FONT></p> </td>
<td width="4%" bordercolor="#000000">
<marquee align="middle" direction="right" scrolldelay="1" bgcolor="gainsboro" scrollamount="2" style="BORDER-RIGHT: black 1px outset; BORDER-TOP: black 1px outset; FONT-SIZE: xx-small; BORDER-LEFT: black 1px outset; WIDTH: 133px; COLOR: #000080; BORDER-BOTTOM: black 1px outset; HEIGHT: 13px"
behavior="slide"
>███████████████████████████████████████████████████████████████████████████████</marquee>
</td><td width="45%" align=left><div id=per></div></td>
</tr>
</table>
</BODY>
</HTML>
Asp import word and excel
Note: The "data" in the two functions is the id of the table to be exported in the web page.
<input type="hidden" name="out_word" onclick="vbscript:buildDoc" value="Export to word" class="notPrint">
<input type="hidden" name="out_excel" onclick="AutomateExcel();" value="Export to excel" class="notPrint">
Export to Excel code
<SCRIPT LANGUAGE="JavaScript">
<!--
function AutomateExcel()
{
// Start Excel and get Application object.
var oXL = new ActiveXObject("");
// Get a new workbook.
var oWB = ();
var oSheet = ;
var table = ;
var hang = ;
var lie = (0).;
// Add table headers going cell by cell.
for (i=0;i<hang;i++)
{
for (j=0;j<lie;j++)
{
(i+1,j+1).Value = (i).cells(j).innerText;
}
}
= true;
= true;
}
//-->
</SCRIPT>
Export to Word code
<script language="vbscript">
Sub buildDoc
set table =
row =
column = (1).
Set objWordDoc = CreateObject("")
' theTemplate, False
=True
Dim theArray(20,10000)
for i=0 to row-1
for j=0 to column-1
theArray(j+1,i+1) = (i).cells(j).innerTEXT
next
next
("Comprehensive Query Result Set") //Show table title
("")
Set rngPara = (1).Range
With rngPara
.Bold = True //Set the title to bold
. = 1 //Center the title
. = "Lishu" //Set the title font
. = 18 //Set the title font size
End With
Set rngCurrent = (3).Range
Set tabCurrent = (rngCurrent,row,column)
for i = 1 to column
(1).Rows(1).Cells(i). theArray(i,1)
(1).Rows(1).Cells(i).=1
next
For i =1 to column
For j = 2 to row
(1).Rows(j).Cells(i). theArray(i,j)
(1).Rows(j).Cells(i).=1
Next
Next
End Sub
</SCRIPT>
Previous page1234567891011121314151617181920Next pageRead the full text