📄 validate.js
字号:
if (month.indexOf('0')==0)
{
month=month.substr(1,month.length);
}
// 下面操作获得日期
var day=getdate.substr(getdate.lastIndexOf('-')+1,getdate.length);
if (day.indexOf('0')==0)
{
day=day.substr(1,day.length);
}
if ((month==4 || month==6 || month==9 || month==11) && (day>30)) // 4,6,9,11月份日期不能超过30
{
flag=false;
}
if (month==2) // 判断2月份
{
if (LeapYear(year))
{
if (day>29 || day<1){ flag=false; }
}
else
{
if (day>28 || day<1){flag=false; }
}
}
else
{
flag=true;
}
}
if (flag==false)
{
alert(message+"!\n"); //为空时出现的提示
name.focus();
name.select();
return false;
}
}
//判断是否闰年
//参数 intYear 代表年份的值
//return true: 是闰年 false: 不是闰年
function LeapYear(intYear) {
if (intYear % 100 == 0)
{
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
// ===============判断电话,可以为空================ //
if (type.indexOf("tel")!=-1)
{
if (name.value!="")
{
if (value.search(/^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{8}$/)==-1 && value.search(/^(\([0-9]{4}\)|[0-9]{4}-)[0-9]{7}$/)==-1)
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
}
}
// ===============判断电话,不能为空================ //
if (type.indexOf("r_tel")!=-1)
{
if (name.value=="")
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
if (value.search(/^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{8}$/)==-1 && value.search(/^(\([0-9]{4}\)|[0-9]{4}-)[0-9]{7}$/)==-1)
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
}
// ===============判断手机,可以为空================ //
if (type.indexOf("mod")!=-1)
{
if (name.value!="")
{
if (value.search(/^[0-9]{11}$/)==-1)
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
}
}
// ===============判断手机,不能为空================ //
if (type.indexOf("r_mod")!=-1)
{
if (name.value=="")
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
if (value.search(/^[0-9]{11}$/)==-1)
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
}
// ===============判断街道================ //
if (type.indexOf("city")!=-1)
{
if (name.value!="")
{
if (value.search(/^.{1,}(市|镇|乡).{1,}(路|街|道).{1,}号.{0,}$/)==-1)
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
}
}
// ===============判断街道,不能为空================ //
if (type.indexOf("r_city")!=-1)
{
if (name.value=="")
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
if (value.search(/^.{1,}(市|镇|乡).{1,}(路|街|道).{1,}号.{0,}$/)==-1)
{
alert(message+"!\n");
name.focus();
name.select();
return false;
}
}
}
}
}
// 下面是弹出无边窗口
minimizebar="js/images/minimize.gif";
minimizebar2="js/images/minimize.gif";
closebar="js/images/close.gif";
closebar2="js/images/close.gif";
icon="js/images/ie.gif";
function noBorderWin(fileName,w,h,titleBg,moveBg,titleColor,titleWord,scr)
{
var contents="<html>"+
"<head>"+
"<title>"+titleWord+"</title>"+
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">"+
"<object id=hhctrl type='application/x-oleobject' classid='clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11'><param name='Command' value='minimize'></object>"+
"</head>"+
"<body topmargin=0 leftmargin=0 scroll=no onselectstart='return false' ondragstart='return false'>"+
" <table height=100% width=100% cellpadding=0 cellspacing=1 bgcolor="+titleBg+" id=mainTab>"+
" <tr height=18 style=cursor:default; onmousedown='x=event.x;y=event.y;setCapture();mainTab.bgColor=\""+moveBg+"\";' onmouseup='releaseCapture();mainTab.bgColor=\""+titleBg+"\";' onmousemove='if(event.button==1)self.moveTo(screenLeft+event.x-x,screenTop+event.y-y);'>"+
" <td width=22 align=center><img border=0 src="+icon+"> </td>"+
" <td width="+w+"><span style=font-size:12px;color:"+titleColor+";font-family:宋体;font-weight:bold;position:relative;top:1px;>"+titleWord+"</span></td>"+
" <td width=14><img border=0 src="+minimizebar+" onmousedown=hhctrl.Click(); onmouseover=this.src='"+minimizebar2+"' onmouseout=this.src='"+minimizebar+"'></td>"+
" <td width=14><img border=0 src="+closebar+" onmousedown=self.close(); onmouseover=this.src='"+closebar+"' onmouseout=this.src='"+closebar+"'></td>"+
" </tr>"+
" <tr height=*>"+
" <td colspan=4>"+
" <iframe name=nbw_v6_iframe src="+fileName+" scrolling="+scr+" width=100% height=100% frameborder=0></iframe>"+
" </td>"+
" </tr>"+
" </table>"+
"</body>"+
"</html>";
pop=window.open("","_blank","fullscreen=yes");
pop.resizeTo(w,h);
pop.moveTo((screen.width-w)/2,(screen.height-h)/2);
pop.document.writeln(contents);
if(pop.document.body.clientWidth!=w||pop.document.body.clientHeight!=h)
{
temp=window.open("","nbw_v6");
temp.close();
window.showModalDialog("about:<"+"script language=javascript>window.open('','nbw_v6','fullscreen=yes');window.close();"+"</"+"script>","","dialogWidth:0px;dialogHeight:0px");
pop2=window.open("","nbw_v6");
pop2.resizeTo(w,h);
pop2.moveTo((screen.width-w)/2,(screen.height-h)/2);
pop2.document.writeln(contents);
pop.close();
}
}
// 下面是日期控件
var weekend = [0,6];
var weekendColor = "#F4F7EA";
var fontface = "Verdana";
var fontsize = 2;
var gNow = new Date();
var ggWinCal;
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
Calendar.Months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
if ((p_month == null) && (p_year == null)) return;
if (p_WinCal == null)
this.gWinCal = ggWinCal;
else
this.gWinCal = p_WinCal;
if (p_month == null) {
this.gMonthName = null;
this.gMonth = null;
this.gYearly = true;
} else {
this.gMonthName = Calendar.get_month(p_month);
this.gMonth = new Number(p_month);
this.gYearly = false;
}
this.gYear = p_year;
this.gFormat = p_format;
this.gBGColor = "white";
this.gFGColor = "black";
this.gTextColor = "black";
this.gHeaderColor = "black";
this.gReturnItem = p_item;
}
Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;
function Calendar_get_month(monthNo) {
return Calendar.Months[monthNo];
}
function Calendar_get_daysofmonth(monthNo, p_year) {
/*
Check for leap year ..
1.Years evenly divisible by four are normally leap years, except for...
2.Years also evenly divisible by 100 are not leap years, except for...
3.Years also evenly divisible by 400 are leap years.
*/
if ((p_year % 4) == 0) {
if ((p_year % 100) == 0 && (p_year % 400) != 0)
return Calendar.DOMonth[monthNo];
return Calendar.lDOMonth[monthNo];
} else
return Calendar.DOMonth[monthNo];
}
function Calendar_calc_month_year(p_Month, p_Year, incr) {
/*
Will return an 1-D array with 1st element being the calculated month
and second being the calculated year
after applying the month increment/decrement as specified by 'incr' parameter.
'incr' will normally have 1/-1 to navigate thru the months.
*/
var ret_arr = new Array();
if (incr == -1) {
// B A C K W A R D
if (p_Month == 0) {
ret_arr[0] = 11;
ret_arr[1] = parseInt(p_Year) - 1;
}
else {
ret_arr[0] = parseInt(p_Month) - 1;
ret_arr[1] = parseInt(p_Year);
}
} else if (incr == 1) {
// F O R W A R D
if (p_Month == 11) {
ret_arr[0] = 0;
ret_arr[1] = parseInt(p_Year) + 1;
}
else {
ret_arr[0] = parseInt(p_Month) + 1;
ret_arr[1] = parseInt(p_Year);
}
}
return ret_arr;
}
function Calendar_print() {
ggWinCal.print();
}
function Calendar_calc_month_year(p_Month, p_Year, incr) {
/*
Will return an 1-D array with 1st element being the calculated month
and second being the calculated year
after applying the month increment/decrement as specified by 'incr' parameter.
'incr' will normally have 1/-1 to navigate thru the months.
*/
var ret_arr = new Array();
if (incr == -1) {
// B A C K W A R D
if (p_Month == 0) {
ret_arr[0] = 11;
ret_arr[1] = parseInt(p_Year) - 1;
}
else {
ret_arr[0] = parseInt(p_Month) - 1;
ret_arr[1] = parseInt(p_Year);
}
} else if (incr == 1) {
// F O R W A R D
if (p_Month == 11) {
ret_arr[0] = 0;
ret_arr[1] = parseInt(p_Year) + 1;
}
else {
ret_arr[0] = parseInt(p_Month) + 1;
ret_arr[1] = parseInt(p_Year);
}
}
return ret_arr;
}
// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
new Calendar();
Calendar.prototype.getMonthlyCalendarCode = function() {
var vCode = "";
var vHeader_Code = "";
var vData_Code = "";
// Begin Table Drawing code here..
vCode = vCode + "<table width='100%' bordercolordark='#ffffff' bordercolorlight='#8EA525' bgcolor='#FAFCF1' border='1' cellspacing='0' cellpadding='0' >"
vHeader_Code = this.cal_header();
vData_Code = this.cal_data();
vCode = vCode + vHeader_Code + vData_Code;
vCode = vCode + "</TABLE>";
return vCode;
}
Calendar.prototype.show = function() {
var vCode = "";
this.gWinCal.document.open();
// Setup the page...
this.wwrite("<html>");
this.wwrite("<head><title>Calendar</title>");
this.wwrite("</head>");
this.wwrite("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
this.wwrite("<style type='text/css'>");
this.wwrite(".table_dropshadow{FILTER:dropshadow(color=#EDEDF8,offx=3.3,offy=3.3,positive=1);}");
this.wwrite(".font_dropshadow{FILTER: dropshadow(color=#F2F8DA,offx=1,offy=1);}");
this.wwrite("td { font-size: 10pt; color: #666600}");
this.wwrite("tr { height: 25px} .table_head_font{font-size: 14px; color: #7B7B00}");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -