//常用验证正则表达式
var  emailStr = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var  phoneStr = /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
var  mobileStr = /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/;
var  zipStr = /^[0-9]\d{5}$/;
var  englishStr = /^[A-Za-z]+$/;


String.prototype.is_null=function(){ 
	if(this.trim().length < 1 || this == '0')
	{
		return true;
	}
	return false;
}

String.prototype.is_price=function(){ 
	var reg	= new RegExp(/^\d*\.?\d{0,2}$/);
	if (reg.test(this) ) return true;
	return false;
	
}

String.prototype.is_int=function(){ 
	var  str =  /^\d+$/;
	if (str.test(this) ) return true;
	return false;
	
}


String.prototype.checkUser = function(){
	var  str =  /^[A-Za-z0-9\_\u0391-\uFFE5]+$/;
	if ( !str.test(this) ) return false;
	
	//this.replace(/[\u0391-\uFFE5]/g,"AA");
	var _this = this.replace(/[\u0391-\uFFE5]/g,"AA");
	if (_this.length <4 || _this.length >16) return;
	
	return true;
}

String.prototype.checkPwd = function(){
	if (this.length <6 || this.length >16) return false;
	//alert(this);
	return true;
}

String.prototype.checkMail = function(){
	var  str =  /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if ( !str.test(this) ) return false;
	return true;
}

String.prototype.checkName = function(){
	var  str =  /^[\u0391-\uFFE5]{2,4}$/;
	if (!str.test(this)) return false;
	return true;
}

String.prototype.len = function(){
	//this.replace(/[\u0391-\uFFE5]/g,"AA");
	this.replace(/[\u0391-\uFFE5]/g,"AA");
	return this.len;	
}

String.prototype.checkUrl = function(){
	var  str = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	if (!str.test(this)) return false;
	return true;
}

//去除表单的留白
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.checkNull=function(){ 
	return (str.value.trim().length < 1);
} 


String.prototype.len=function(){ 
	return this.replace(/[^\x00-\xff]/g,"**").length; 
} 

/*
//Set maxlength for multiline TextBox 
function setMaxLength(object,length) 
{ 
	var result = true; 
	var controlid = document.selection.createRange().parentElement().id; 
	var controlValue = document.selection.createRange().text; 
	if (controlid == object.id && controlValue != "") 
	{ 
	result = true; 
	} 
	else if (object.value.len() >= length) 
	{ 
	result = false; 
	} 
	if (window.event) 
	{ 
	window.event.returnValue = result; 
	return result; 
	} 
} 

//Check maxlength for multiline TextBox when paste 
function limitPaste(object,length) 
{ 
	var tempLength = 0; 
	if(document.selection) 
	{ 
	if(document.selection.createRange().parentElement().id == object.id) 
	{ 
	tempLength = document.selection.createRange().text.len(); 
	} 
	} 
	var tempValue = window.clipboardData.getData("Text"); 
	tempLength = object.value.len() + tempValue.len() - tempLength; 
	if (tempLength > length) 
	{ 
	tempLength -= length; 
	//alert(tempLength); 
	//alert(tempValue); 
	var tt=""; 
	for(var i=0;i<tempValue.len()-tempLength;i++) 
	{ 
	if(tt.len()<(tempValue.len()-tempLength)) 
	tt=tempValue.substr(0,i+1); 
	else 
	break; 
	} 
		tempValue=tt; 
		window.clipboardData.setData("Text", tempValue); 
	} 
	window.event.returnValue = true; 
} 

function chklength(strTemp){ var i,sum; sum=0; for(i=0;i<strTemp.length;i++){ if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255)) sum=sum+1; else sum=sum+3; } return sum;}

*/

