⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auction.js

📁 javascript语言获取日期时间
💻 JS
📖 第 1 页 / 共 2 页
字号:
function checkauction(note,flag){
  var IsChecked = false;
  var obj =document.forms[0].elements;		   
 for(var i=0;i<obj.length;i++)
 {
	 if(obj[i].type=="radio")
	 {
	     if(obj[i].checked)
			{
			      IsChecked  = true;
			       if(flag==true)
			       {
                    window.alert("此商品已经参加竞拍,请选择其它的商品进行竞拍");
                     return false;
                   }
                     else if(flag==false)
                     {
                      return true;
			        }				       
			    }		
     } 
 
 }
     if (IsChecked ==false)
			{
			   window.alert(note);
			}	
		    return IsChecked ;
}//验证开始日期选择
	function checkadd(currentDate,note1,objId1,note2,objId2)
	{
	    var start_date = document.getElementById('start_date');
	 	var start_value = start_date.value;
	 	var startMonth = start_value.substring(5,start_value.lastIndexOf ("-"));
	 	var startDay = start_value.substring(start_value.length,start_value.lastIndexOf ("-")+1);
	 	var startYear = start_value.substring(0,start_value.indexOf ("-"));	
        
	 	var currentMonth = currentDate.substring(5,currentDate.lastIndexOf ("-"));
		var currentDay = currentDate.substring(currentDate.length,currentDate.lastIndexOf ("-")+1);
		var currentYear = currentDate.substring(0,currentDate.indexOf ("-"));
		
		if(Date.parse(startMonth+"/"+startDay+"/"+startYear) -  Date.parse(currentMonth+"/"+currentDay+"/"+currentYear)<86400000)
	    {
	      window.alert("起始日期要晚于当前日期一天!");
	      return false;
	    }
		else if(!checkNum(note1,objId1))
		{
		return false;
		}
		else if(!checkNum(note2,objId2))
		{
            return false;
         } 		   	 		 
	    else
	    {
	        return true;
	    }	
	   	}
     //去除字符串的首尾的空格
	function trim(str)
	{
       return str.replace(/(^\s*)|(\s*$)/g, "");
    }
	//检查是否是数字
	    function checkNum(note,objId)
	    {
	    	var obj = document.getElementById(objId);
	    	var number = trim(obj.value);	    	
	    	if(/\D/.test(number))
	    	{
		    	alert(note+'只能输入数字!');	
		    	obj.value="";	    	
		    	obj.focus();
		    	return false;
	    	}
	    	else
	    	{
	    		return true;
	    	}
	    }
<!--
/**
* 返回日期
* @param d the delimiter
* @param p the pattern of your date
*/
String.prototype.toDate = function(x, p) {
if(x == null) x = "-";
if(p == null) p = "ymd";
var a = this.split(x);
var y = parseInt(a[p.indexOf("y")]);
//remember to change this next century ;)
if(y.toString().length <= 2) y += 2000;
if(isNaN(y)) y = new Date().getFullYear();
var m = parseInt(a[p.indexOf("m")]) - 1;
var d = parseInt(a[p.indexOf("d")]);
if(isNaN(d)) d = 1;
return new Date(y, m, d);
}

/**
* 格式化日期
* @param   d the delimiter
* @param   p the pattern of your date
* @author meizz
*/
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 1990
* @param   endYear   2010
* @param   lang      0(中文)|1(英语) 可自由扩充
* @param   dateFormatStyle "yyyy-MM-dd";
* @version 2006-04-01
* @author KimSoft (jinqinghua [at] gmail.com)
* @update
*/
function Calendar(beginYear, endYear, lang, dateFormatStyle) {
this.beginYear = 2007;
this.endYear = 2012;
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.form = null;

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


this.colors = {
"cur_word"      : "#FFFFFF", //当日日期文字颜色
"cur_bg"        : "#00FF00", //当日日期单元格背影色
"sun_word"      : "#FF0000", //星期天文字颜色
"sat_word"      : "#0000FF", //星期六文字颜色
"td_word_light" : "#333333", //单元格文字颜色
"td_word_dark" : "#CCCCCC", //单元格文字暗色
"td_bg_out"     : "#fff0f5", //单元格背影色
"td_bg_over"    : "#FFCC00", //单元格背影色
"tr_word"       : "#FF6347", //日历头文字颜色
"tr_bg"         : "#FFFFF0", //日历头背影色
"input_border" : "#CCCCCC", //input控件的边框颜色
"input_bg"      : "#EFEFEF"   //input控件的背影色
}

this.draw();
this.bindYear();
this.bindMonth();
this.changeSelect();
this.bindData();
}

/**
* 日历类属性(语言包,可自由扩展)
*/
Calendar.language = {
"year"   : [[""], [""]],
"months" : [["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
        ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]
         ],
"weeks" : [["日","一","二","三","四","五","六"],
        ["SUN","MON","TUR","WED","THU","FRI","SAT"]
         ],
"clear" : [["清空"], ["CLS"]],
"today" : [["今天"], ["TODAY"]],
"close" : [["关闭"], ["CLOSE"]]
}

Calendar.prototype.draw = function() {
calendar = this;

var mvAry = [];
mvAry[mvAry.length] = ' <form name="calendarForm" style="margin: 0px;">';
mvAry[mvAry.length] = '    <table width="100%" border="0" cellpadding="0" cellspacing="1">';
mvAry[mvAry.length] = '      <tr>';
mvAry[mvAry.length] = '        <th align="left" width="1%"><input style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:16px;height:20px;" name="prevMonth" type="button" id="prevMonth" value="&lt;" /></th>';
mvAry[mvAry.length] = '        <th align="center" width="98%" nowrap="nowrap"><select name="calendarYear" id="calendarYear" style="font-size:12px;"></select><select name="calendarMonth" id="calendarMonth" style="font-size:12px;"></select></th>';
mvAry[mvAry.length] = '        <th align="right" width="1%"><input style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:16px;height:20px;" name="nextMonth" type="button" id="nextMonth" value="&gt;" /></th>';
mvAry[mvAry.length] = '      </tr>';
mvAry[mvAry.length] = '    </table>';
mvAry[mvAry.length] = '    <table id="calendarTable" width="100%" style="border:0px solid #CCCCCC;background-color:#FFFFFF" border="0" cellpadding="3" cellspacing="1">';
mvAry[mvAry.length] = '      <tr>';
for(var i = 0; i < 7; i++) {
    mvAry[mvAry.length] = '      <th style="font-weight:normal;background-color:' + calendar.colors["tr_bg"] + ';color:' + calendar.colors["tr_word"] + ';">' + Calendar.language["weeks"][this.lang][i] + '</th>';
}
mvAry[mvAry.length] = '      </tr>';
for(var i = 0; i < 6;i++){
    mvAry[mvAry.length] = '    <tr align="center">';
    for(var j = 0; j < 7; j++) {
      if (j == 0){
        mvAry[mvAry.length] = ' <td style="cursor:default;color:' + calendar.colors["sun_word"] + ';"></td>';
      } else if(j == 6) {
        mvAry[mvAry.length] = ' <td style="cursor:default;color:' + calendar.colors["sat_word"] + ';"></td>';
      } else {
        mvAry[mvAry.length] = ' <td style="cursor:default;"></td>';
      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -