
function checkMail(input)
{
	var value = trim(input.value); //去除文本域左右的空格
	if(value.length == 0 || input.value=="")
	{
		//获取没有空格的焦点
		//input.focus();
		input.value = value;
		textDescription("e_mail"," 邮箱不能为空","red");
		return false;
	}
	else if(!validate_email(input))
	{
		//input.focus();
		input.value=value;
		textDescription("e_mail"," 邮箱格式不正确，正确格式:sina@sina.com","red");
		return false;
	}
	else 
	{

		return true;
	}
}

function f_check_particularTitleChar(obj)   
{          
    var s = obj.value; 
    var reg =/[^\x00-\xff]/g; 
    var re=/^[A-Za-z0-9]*$/;
    if(reg.test(s) || re.test(s))
    {
    	return true;
    }
    else    
    {   
        document.getElementById("e_title").innerHTML="<font color='red'>求购标题中不能包含单字节字符</font>";
        return false;   
    }
}

function checkproductTitle(input){
	 var text = trim(input.value);
	 
	 if(f_check_particularTitleChar(f1.productTitle)==false)
	 {
	     document.getElementById("e_title").innerHTML="<font color='red'>求购标题不能包含单字节字符</font>";
	 }
	 if(text.length<1||text=="")
     {
      	document.getElementById("e_title").innerHTML="<font color='red'>标题不能为空</font>";

    	return false;
	 }
	 if(text.indexOf("供应") >= 0||text.indexOf("促销") >= 0
	 ||text.indexOf("抢购") >= 0||text.indexOf("热卖") >= 0
	 ||text.indexOf("甩卖") >= 0||"供货".indexOf(text) >= 0
	 ||text.indexOf("供货") >= 0||"供应".indexOf(text) >= 0
	 ||"促销".indexOf(text) >= 0||"抢购".indexOf(text) >= 0
	 ||"热卖".indexOf(text) >= 0||"甩卖".indexOf(text) >= 0
	 ||"诚招".indexOf(text) >= 0||text.indexOf("诚招") >= 0
	 ||"招".indexOf(text) >= 0||text.indexOf("招") >= 0
	 ||"卖".indexOf(text) >= 0||text.indexOf("卖") >= 0
	 ||"销".indexOf(text) >= 0||text.indexOf("销") >= 0
	 ||"供".indexOf(text) >= 0||text.indexOf("供") >= 0)
     {
      	document.getElementById("e_title").innerHTML="<font color='red'>标题中不能出现和求购不合的促销词语</font>";

    	return false;
	 }
	 if(text.length>30)
	 {
    	document.getElementById("e_title").innerHTML="<font color='red'>标题输入太长，请重新输入</font>";
	    return false;
	 } 
	 else
	 {
    	document.getElementById("e_title").innerHTML="<font color='green'>标题输入正常</font>";
	    return true;
	 }
}
function f_check_particularNameChar(obj)   
{          
    var s = obj.value; 
    var reg =/[^\x00-\xff]/g; 
    var re=/^[A-Za-z0-9]*$/;
    if(reg.test(s) || re.test(s))
    {
    	return true;
    }
    else    
    {   
        document.getElementById("e_productName").innerHTML="<font color='red'>求购名称不能包含单字节字符</font>";
        return false;   
    }
}
	function checkproductName(input){
	
	 var text =  trim(input.value);
	 
	  if(f_check_particularNameChar(f1.productName)==false)
	 {
	     document.getElementById("e_productName").innerHTML="<font color='red'>求购名称不能包含单字节字符</font>";
	      return false;
	 }
	 if(text.length<1||text=="")
     {
      	document.getElementById("e_productName").innerHTML="<font color='red'>产品名称不能为空</font>";
		return false;
	 }
	 if(text.indexOf("供应") >= 0||text.indexOf("促销") >= 0
	 ||text.indexOf("抢购") >= 0||text.indexOf("热卖") >= 0
	 ||text.indexOf("甩卖") >= 0||text.indexOf("热购") >= 0
	 ||text.indexOf("供货") >= 0||"供应".indexOf(text) >= 0
	 ||"促销".indexOf(text) >= 0||"抢购".indexOf(text) >= 0
	 ||"热卖".indexOf(text) >= 0||"甩卖".indexOf(text) >= 0
	 ||"热购".indexOf(text) >= 0||"供货".indexOf(text) >= 0)
     {
      	document.getElementById("e_productName").innerHTML="<font color='red'>产品中不能出现和求购不合的促销词语</font>";

    	return false;
	 }
	 if(text.length>30)
	 {
     	document.getElementById("e_productName").innerHTML="<font color='red'>产品名称输入太长，请重新输入</font>";
    	return false;
	 } 
	 else
	 {
     	document.getElementById("e_productName").innerHTML="<font color='green'>产品名称输入正常</font>";
	    return true;
	 }
}

function checkproductCategory(input)
{
	 var text = trim(input.value);
      if(text=="")
      {
      	   document.getElementById("e_categoryName").innerHTML="<font color='red'>求购行业不能为空</font>";
   	 	   return false;
	  }
	  else
	  {
	  	   document.getElementById("e_categoryName").innerHTML="<font color='green'>求购行业输入有效</font>";
   	 	   return true;
	  }
}

function f_check_naturalnumber(obj)   
{          
    var s = obj.value;   
    if (/^[0-9]+$/.test( s ))   
    {   
       return true;   
    }    
    else    
    {   
        document.getElementById("e_buyNumber").innerHTML="<font color='red'>输入信息不规范  </font>";
        return false;   
    }
}   
<!-- pan duan shu ru de shi fou shi shu zi-->
function checkbuyNumber(input)
{
	 var text =  trim(input.value);
	 if(f_check_naturalnumber(f1.Number)==false)
	 {
	     document.getElementById("e_buyNumber").innerHTML="<font color='red'>购买数量不能为空</font>";
	 }
     if(text.length>6||text.length<1||text==""||text==0)
     {
      	 document.getElementById("e_buyNumber").innerHTML="<font color='red'>购买数量长度超出有效求购范围，请重新输入</font>";
    	 return false;
	 }
	 else
	 {
    	 document.getElementById("e_buyNumber").innerHTML="<font color='green'>购买数量输入正常</font>";
    	 return true;
	 }
}

function checkmanufacturers(input){
	 var text = trim(input.value);
	if(text.length<1||text==""){
      document.getElementById("e_manufacturers").innerHTML="<font color='red'>生产商不能为空</font>";

    return false;
	}if(text.length>50){
	    document.getElementById("e_manufacturers").innerHTML="<font color='red'>生产商输入太长，请重新输入</font>";
	   
	
	    return false;
	} else{
	    document.getElementById("e_manufacturers").innerHTML="<font color='green'>生产商输入正常</font>";
	    
	    return true;
	}
}

function f_check_productRequest(obj)   
{          
    var s = obj.value; 
    var reg =/[^\x00-\xff]/g; 
    var re=/^[A-Za-z0-9]*$/;
    if(reg.test(s) || re.test(s))
    {
    	return true;
    }
    else    
    {
        document.getElementById("e_productRequest").innerHTML="<font color='red'>求购要求中不能包含单字节字符</font>";
        return false;   
    }
}

function checkproductRequest(input)
{
	 var text = trim(input.value);
	 
	  if(f_check_productRequest(f1.productRequest)==false)
	  {
	     document.getElementById("e_productRequest").innerHTML="<font color='red'>求购要求输入不符合规范</font>";
	  }
      if(text.length>200){
    document.getElementById("e_productRequest").innerHTML="<font color='red'>求购要求输入太长，请重新输入</font>";
   

    return false;
} else{
    document.getElementById("e_productRequest").innerHTML="<font color='green'>求购要求输入正常</font>";
    
    return true;
}}
function checkproductRequest(input)
{
	var text =  trim(input.value);
    if(text.length>500)
    {
     	document.getElementById("e_productRequest").innerHTML="<font color='red'>要求过长太长，请重新输入</font>";
     	return false;
	} 
	else
	{
   	 	document.getElementById("e_productRequest").innerHTML="";
   		return true;
	}
}
function isphone(obj)   
{
    var s = obj.value;
    if (/^[0-9]+$/.test(s))   
    {
       return true;   
    }    
    else    
    {
        return false;   
    }
}
function check_phone(input)
{
	 var text = trim(input.value);
	 
	if(text == "" || text.length <= 0)
	 {
	     document.getElementById("e_phone").innerHTML="<font color='red'>电话号码不能为空</font>";
		 return false;
	 }
	 if(isphone(f1.uPhone)==false)
	 {
	     document.getElementById("e_phone").innerHTML="<font color='red'>格式不正确</font>";
		 return false;
	 }
     if(text.length>20)
     {
      	 document.getElementById("e_phone").innerHTML="<font color='red'>超出范围，请重新输入</font>";
    	 return false;
	 }
	 else
	 {
    	 document.getElementById("e_phone").innerHTML="<font color='green'>输入正常</font>";
    	 return true;
	 }
}
function f_checkqq_naturalnumber(obj)   
{          
    var s = obj.value;  
    if (/^[0-9]+$/.test(s))   
    {
       return true;   
    }    
    else    
    {   
        return false;   
    }
}
function checkQq(input)
{
	 var text =  trim(input.value);
	 if(text == "" || text.length <= 0)
	 {
	     document.getElementById("e_qq").innerHTML="<font color='red'>QQ号码不能为空</font>";
		 return false;
	 }
	 if(f_checkqq_naturalnumber(f1.uQq)==false)
	 {
	     document.getElementById("e_qq").innerHTML="<font color='red'>输入信息不规范</font>";
		 return false;
	 }
     if(text.length>20)
     {
      	 document.getElementById("e_qq").innerHTML="<font color='red'>超出范围，请重新输入</font>";
    	 return false;
	 }
	 else
	 {
    	 document.getElementById("e_qq").innerHTML="<font color='green'>输入正常</font>";
    	 return true;
	 }
}
function check_city(input)
{
	var value = input.value;
	if(input.value=="")   //是否为空
	{
		//获取没有空格的焦点
		value = "";
		document.getElementById("e_ucity").innerHTML="<font color='red'>请选择您所在城市</font>";
		return false;
	}
	else 
	{
		document.getElementById("e_ucity").innerHTML="<font color='green'>城市输入有效</font>";
		return true;
	}
}
function checkAll()
{
   if(checkproductTitle(f1.productTitle)== false){
    document.getElementById("e_title").innerHTML="<font color='red'>标题输入错误，请重新输入</font>";
   }else if(checkproductName(f1.productName) == false ){
        document.getElementById("e_productName").innerHTML="<font color='red'>产品名称输入错误，请重新输入</font>";
   }else if(checkproductCategory(f1.cid)== false){
       document.getElementById("e_categoryName").innerHTML="<font color='red'>行业输入有误,请重新输入</font>";
   }else if(checkbuyNumber(f1.Number)== false || f_check_naturalnumber(f1.Number)==false){
       document.getElementById("e_buyNumber").innerHTML="<font color='red'>购买数量输入错误,请重新输入</font>";
   }else{
      f1.submit();
   }
}

function islogincheckAll(){
   if(checkproductTitle(f1.productTitle)== false){
    	document.getElementById("e_title").innerHTML="<font color='red'>标题输入错误，请重新输入</font>";
   }else if(checkproductName(f1.productName) == false ){
        document.getElementById("e_productName").innerHTML="<font color='red'>产品名称输入错误，请重新输入</font>";
   }else if(checkproductCategory(f1.bcid)== false){
       document.getElementById("e_categoryName").innerHTML="<font color='red'>行业输入有误,请重新输入</font>";
   }else if(checkbuyNumber(f1.Number)== false ||f_check_naturalnumber(f1.Number)==false){
       document.getElementById("e_buyNumber").innerHTML="<font color='red'>购买数量输入错误,请重新输入</font>";
   }else if(checkUserName(f1.uUserName)== false){
       document.getElementById("e-uUserName").innerHTML="<font color='red'>你输入的邮箱错误,请重新输入</font>";
   }else if(check_password(f1.uPassword)== false){
       document.getElementById("e_uPassword").innerHTML="<font color='red'>密码输入错误,请重新输入</font>";
   }else if(check_phone(f1.uPhone)== false){
       document.getElementById("e_uPhone").innerHTML="<font color='red'>输入电话有误,请重新输入</font>";
   }else if(check_city(f1.city)== false){
       document.getElementById("e_ucity").innerHTML="<font color='red'>输入城市有误,请重新输入</font>";
   }else if(checkQq(f1.uQq)== false){
       document.getElementById("e_uQq").innerHTML="<font color='red'>输入QQ有误,请重新输入</font>";
   }else{
      f1.submit();
   }
}


function checkAll_1(){
 // if(thehaved(f1.mail,"../client/canreg.jsp")==false){
	//  	   document.getElementById("e_mail").innerHTML="<font color='red'>邮箱已存在，请重新输入</font>";
	 //	}else
		if(checkMail(f1.mail)==false){
		     document.getElementById("e_mail").innerHTML="<font color='red'>邮箱输入错误，请重新输入</font>";
		}else 
   if(checkproductTitle(f1.productTitle)== false){
    document.getElementById("e_title").innerHTML="<font color='red'>标题输入错误，请重新输入</font>";
   }else if(checkproductName(f1.productName) == false ){
        document.getElementById("e_productName").innerHTML="<font color='red'>产品名称输入错误，请重新输入</font>";
   }else if(checkbuyNumber(f1.Number)== false ||f_check_naturalnumber(f1.Number) == false){
       document.getElementById("e_buyNumber").innerHTML="<font color='red'>购买数量输入错误,请重新输入</font>";
   }else {
      f1.submit();
   }
   
}


 function fsubmit(obj){
     var pname = obj.pName;
    if (pname.value == "" || pname.value.length<1) {
		alert("请输入你要查询的相关信息");
		pname.focus();
		return false;
		} if(pname.value>3000) {
		alert("你要查询的相关信息太大请重新输入");
		pname.focus();
		return false;
		}  if(pname.value=="请输入求购名称，查找求购信息"){
		   alert("请输入你要查询的相关信息");
		pname.focus();
		return false;
		}if(pname.value=="请输入信息名称"){   
		   alert("请输入信息名称");
		pname.focus();
		return false;
		}if(pname.value=="请输入信息名称，查找求购信息"){   
		   alert("请输入信息名称，查找求购信息");
		pname.focus();
		return false;
		}
		
		else {
	   obj.submit();
     }
} 



//提示文本,textPosition为文本显示的位置，content为现实的内容
function textDescription(textPosition,content,color)
{
	document.getElementById(textPosition).style.color = color;
	document.getElementById(textPosition).innerText = content;
}

//通用邮箱校验
function validate_email(input)
{
	//邮箱格式规则
	var reb = /^(?:\w+\.?)?\w+@(?:\w+\.?)(com|cn|com.cn|net|org|cc|edu)$/;
	//更广泛的格式规则
	//var reb = /^(?:\w+\.?)?\w+@(?:\w+\.\w+)/; 
	if (reb.test(input.value)) {
		return true;
	}
	return false;
}

//--用户名是否已被注册校验-------------------------------------0--------------
//使用var声明的变量不具有全局性,不使用var声明的变量具有全局性
var xmlHttp;
isExist = false;
//创建XMLHttpRequest对象
function createAjaxObject()
{
	try
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlHttp = new XMLHttpRequest();
		}
		catch(e)
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
	}
}
//开始请求处理
function startRequest(url)
{
	createAjaxObject();
	//使用GET方式进行请求
	xmlHttp.open("GET",url,false);
	//监听请求变化
	xmlHttp.onreadystatechange = startCallback;
	//if(value != null)
	//{
	//	xmlHttp.setRequestHeader("Content-Type","Application/x-www-form-urlencoded");
	//}
	
	xmlHttp.send(null);
	
}

function startCallback()
{
	
	if(xmlHttp.readyState == 4)//请求状态处理完毕
	{
		if(xmlHttp.status == 200)//服务器成功返回,开始处理数据
		{
		    var data = xmlHttp.responseText;
		    //判断输入的用户名是否存在,不存在isExist赋值为false
		    if(data.indexOf("已被注册") > 0)
		    { 
		    	isExist = false;
		    }
		    else
		    {	
		    	isExist = true;
		    }
			document.getElementById("e-uUserName").innerHTML = data;
		}
		return isExist;
	}
}
//运用AJAX进行校验数据是否存在
function checkIsExistUserName(input)
{
	var value = input.value;
	startRequest("client/user/tempcheckun.jsp?username="+value);
	return isExist;
	
}

//---------------------------------------------------------------------------



//用户名校验,检测用户名是否合法
function checkUserName(input)
{
	var value = trim(input.value); //去除文本域左右的空格
	if(value.length == 0 || input.value=="")
	{
		//获取没有空格的焦点
		//input.focus();
		input.value = value;
		document.getElementById("e-uUserName").innerHTML="<font color='red'>您的邮箱不能为空，这个邮箱将作为您的用户登录名</font>";
		return false;
	}
	else if(!validate_email(input))
	{
		//input.focus();
		input.value=value;
		document.getElementById("e-uUserName").innerHTML="<font color='red'>邮箱格式不正确，正确格式:sina@sina.com</font>";
		return false;
	}
	else if(checkIsExistUserName(input) == false)
	{
		document.getElementById("e-uUserName").innerHTML="<font color='red'>用户名已经存在请重新输入</font>";
		return false;
	}
	else
	{
		document.getElementById("e-uUserName").innerHTML="<font color='green'>输入邮箱(系统登录时候的用户名)有效</font>";
		return true;
	}
}

//通用邮箱校验
function validate_email(input)
{
	//邮箱格式规则
	var reb = /^(?:\w+\.?)?\w+@(?:\w+\.?)(com|cn|com.cn|net|org|cc|edu)$/;
	//更广泛的格式规则
	//var reb = /^(?:\w+\.?)?\w+@(?:\w+\.\w+)/; 
	if (reb.test(input.value)) {
		return true;
	}
	return false;
}


function trim(str)
{
	//return str.replace(/(^\s*)/g,""); //去除左边的空格
	//return str.replace(/(\s*$)/g,""); //去除右边的空格
	return str.replace(/(^\s*)|(\s*$)/g, ""); //去除左右两边的空格
}
//校验密码，必须为数字，字母 _ , $组成的8至18为的密码
function validate_password(input)
{
	//var reg = /[\w]{6,18}$/;
	//if(reg.test(input.value))
	if (input.value.indexOf("\"") > 0 ||input.value.indexOf("\'") > 0)
	{
		return false;
	}
	return true;
}
//校验密码强度及合法性
function check_password(input)
{
	var value = input.value;
	if(value.length == 0 || input.value=="")   //是否为空
	{
		//获取没有空格的焦点
		//input.focus();
		value = "";
		textDescription("e-uPassword","请填写密码","red");
		return false;
	}
	else if(value.length < 6 || value.length > 20)  //密码位数控制
	{
		//input.focus();
		input.value=value;
		textDescription("e-uPassword"," 密码由6-20位数字、字母、下划线_、美元符号￥等组成","red");
		return false;
	}
	else if(!validate_password(input))  //密码是否合法	
	{
		input.focus();
		input.value=value;
		textDescription("e-uPassword"," 密码必须为数字、字母、下划线(_)、美元符号($)组成","red");
		return false;
	}
	else 
	{
		document.getElementById("e-uPassword").innerHTML="<font color='green'>密码有效</font>";
	}
}