String.prototype.trim=function() {return this.replace(/(^\s*)|(\s*$)/g,"");} String.prototype.ltrim=function() {return this.replace(/(^\s*)/g,"");} String.prototype.rtrim=function() {return this.replace(/(\s*$)/g,"");} String.prototype.isInteger=function() {return /^(-|\+)?\d+$/.test(this);} String.prototype.isPositiveInteger=function() {return /^\d+$/.test(this);} String.prototype.isNegativeInteger=function() {return /^-\d+$/.test(this);} // date (13:04:06) String.prototype.isTime=function() { var a = this.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/); if (a == null) return false; if (a[1]>24 || a[3]>60 || a[4]>60) return false; return true; } // short date (13:04) String.prototype.isShortTime=function() { var a = this.match(/^(\d{1,2})(:)?(\d{1,2})$/); if (a == null) return false; if (a[1]>24 || a[3]>60) return false; return true; } // date (2003-12-05) String.prototype.isDate=function() { var r = this.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); if(r==null)return false; var d= new Date(r[1], r[3]-1, r[4]); return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]); } // short date (2003-12) String.prototype.isShortDate=function() { var r = this.match(/^(\d{1,4})(-|\/)(\d{1,2})$/); if(r==null)return false; var d= new Date(r[1], r[3]-1, 1); return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]); } // date (2003-12-05 13:04:06) String.prototype.isDateTime=function() { var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; var r = this.match(reg); if(r==null)return false; var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]); } String.prototype.isFloat=function(){ return /^(-?\d+)(\.\d+)?$/.test(this); } String.prototype.onlyChar=function() { return /[^a-zA-Z]/g.test(this); } String.prototype.onlyCharNumber=function() { return /[^0-9a-zA-Z]/g.test(this); } String.prototype.onlyCharNumberUnderline=function() { return /[^0-9a-zA-Z_]/g.test(this); } // char, number, underline dot CharNumberUnderlineDot String.prototype.onlyCNUD=function() { return /^([a-zA-z_]{1})([\w]*)$/g.test(this); } // mail String.prototype.isEmail=function() { return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(this); } //zip String.prototype.isZipCode = function() { return /^\d{6}$/.test(this); } // hanzi String.prototype.existChinese = function() { return /^[\x00-\xff]*$/.test(this); } // to int String.prototype.toInt = function() { return parseInt(this); } // char length String.prototype.charLen = function() { var length = 0; for (var i = 0; i < this.length; i++) { if (this.charCodeAt(i) > 10000) { length++; } length++; } return length; } String.prototype.isEmpty = function() { return this.trim().length == 0; } String.prototype.isNotEmpty = function() { return !this.isEmpty(); } //ID选择 $ = function (id) { return document.getElementById(id); } //名称选择 $n = function (name) { return document.getElementsByName(name); } //节点 $tg = function (name) { return document.getElementsByTagName(name); } //全选功能 function selectedAll(name,obj){ var length=$n(name).length; for(var i=0;i=0){ sortAsc = false; } if(id!=orderByName){ sortAsc=true; } $("orderByNo").value = sortAsc?"asc":"desc"; $("orderByName").value = id; $(doSearch).click(); } //加载排序字段 function loadOrder(doSearch){ var thList=$tg("td"); for ( var i = 0; i < thList.length; i++) { if(thList[i].attributes["sortName"]){ var orderByName=$("orderByName").value; var sortName=thList[i].attributes["sortName"].nodeValue; if(orderByName==sortName){ var sortPic=$("orderByNo").value=="asc"?"↓":"↑"; thList[i].innerHTML+=sortPic; } //改变样式 thList[i].style.cursor="pointer"; //增加click事件 if(thList[i].addEventListener){ thList[i].addEventListener("click",function(){ var sortName1=this.attributes["sortName"].nodeValue; sort(sortName1,doSearch); },false); }else if(thList[i].attachEvent){ thList[i].onclick=function(){ sort(this.sortName,doSearch); }; } } } } function selectAll(eleObj,idname) { var inputObjes = document.getElementsByTagName("input"); if (inputObjes) { for (var i = 0; i < inputObjes.length; i++) { if (inputObjes[i].type == 'checkbox' && inputObjes[i].disabled==false && inputObjes[i].name == idname) { inputObjes[i].checked = eleObj.checked; } } } } function trimAllInputValue() { var inputObjes = document.getElementsByTagName("input"); if (inputObjes) { for (var i = 0; i < inputObjes.length; i++) { if (inputObjes[i] && (inputObjes[i].type == 'text' || inputObjes[i].type == 'password')&& inputObjes[i].disabled == false) { inputObjes[i].value = inputObjes[i].value.trim(); } } } }