//常用验证正则表达式
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  urlStr = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;

var  zipStr = /^[1-9]\d{5}$/;

var  englishStr = /^[A-Za-z]+$/;

var  chineseStr =  /^[\u0391-\uFFE5]+$/;

//显示信息

function msg(msg)
{
	alert(msg);
	return;
}



//获取控件

function getid(id)

{
	var nId = document.getElementById(id);
	return(nId);
}



//去除表单的留白

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, ""); 
} 



//全部选定

function checkall(butid,id)
	{
		var id = document.getElementsByName(id);
		for (var i =0 ;i < id.length; i++)
		{		

			if (butid.checked == true ) {

				 id[i].checked = 1;

				 }else{

				 id[i].checked = 0;

				}
		}
		//butid.checked = (butid.checked==true)?false:true;
}
//删除时确认

function checkdel(){
	if (confirm("真的要删除吗，添加上去很辛苦的呢，考虑一下吧?")){
		return true;

	}
		return false;
}



//检测表单值是否为空

function checknull(sid,smsg)
{
	var mysid = getid(sid)
	if(mysid.value.trim().length < 1)
	{
		msg(smsg);
		mysid.focus();
		return(false);
	}
	return(true);
}

<!-- 
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;}

//--> 
