代码
//中英文字符长度 String.prototype.mb_length = function(){ var len = 0; for(var i = 0; i < this.length; i++) { len += (this.charCodeAt(i) < 0 || this.charCodeAt(i) > 255) ? 1 : 0.5; } return len; };
//判断是否"yyyy-MM-dd HH:mm:ss" "yyyy/MM/dd HH:mm:ss" 格式时间 String.prototype.isTime = function() { //alert("ooooooo"); var r = this.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/); 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]); };