﻿
//用户登录
function user_login()
{	

	if(document.login_form.user_name.value == "")
	{
		window.alert ("Please enter the user name！")
		document.login_form.user_name.focus();
		return false;
	}

	if (document.login_form.user_pwd.value == "")
	{
		window.alert ("Please enter password！")
		document.login_form.user_pwd.focus();
		return false;
	}
	
	return true;
	
}

//用户注册
function user_reg()
{		
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.user_mail.value;


	if(document.action_form.user_name.value == "")
	{
		window.alert ("Please enter user name！")
		document.action_form.user_name.focus();
		return false;
	}

	if (document.action_form.user_pwd.value == "")
	{
		window.alert ("Please enter password！")
		document.action_form.user_pwd.focus();
		return false;
	}
	if (document.action_form.user_pwd1.value == "")
	{
		window.alert ("Please enter the password again！")
		document.action_form.user_pwd1.focus();
		return false;
	}
	
	if (document.action_form.user_pwd.value != "" && document.action_form.user_pwd.value.length < 6  )
	{
		window.alert ("The password can not less 6 characters！")
		document.action_form.user_pwd.focus();
		return false;
	}
	
	if (document.action_form.user_pwd.value != document.action_form.user_pwd1.value)
	{
		window.alert ("Your password is not the same！")
		document.action_form.user_pwd.focus();
		return false;
	}
	

	if (document.action_form.user_true_name.value == "")
	{
		window.alert ("Please enter your real name！")
		document.action_form.user_true_name.focus();
		return false;
	}	
	
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.user_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.user_mail.focus();
		return false;
	}
	
	if (document.action_form.user_mail_bk.value != '')
	{
    	if(reg.test(document.action_form.user_mail_bk.value) == false)
		{
			window.alert("Your email address is incorrect, please try again！");
			document.action_form.user_mail_bk.focus();
			return false;
		}
	}
	
	if (document.action_form.vcode.value == "")
	{
		window.alert ("Please enter verifiation code！")
		document.action_form.vcode.focus();
		return false;
	}
	
	return true;
	
}

//用户修改
function user_edit()
{		
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.user_mail.value;


	if (document.action_form.check_pwd.value == "")
	{
		window.alert ("Please enter password！")
		document.action_form.check_pwd.focus();
		return false;
	}

	if (document.action_form.user_pwd.value != "" && document.action_form.user_pwd.value.length < 6  )
	{
		window.alert ("The password can not less 6 characters！")
		document.action_form.user_pwd.focus();
		return false;
	}
	if (document.action_form.user_pwd.value != document.action_form.user_pwd1.value)
	{
		window.alert ("Your password is not the same！")
		document.action_form.user_pwd.focus();
		return false;
	}
	
	if (document.action_form.user_true_name.value == "")
	{
		window.alert ("Please enter your real name！")
		document.action_form.user_true_name.focus();
		return false;
	}	
	
	
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.user_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.user_mail.focus();
		return false;
	}
	
	if (document.action_form.user_mail_bk.value != '')
	{
    	if(reg.test(document.action_form.user_mail_bk.value) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.user_mail_bk.focus();
			return false;
		}
	}
	
	
	return true;
	
}



function search_check(root_url)
{
	if(document.search_form.search_key.value == "")
	{
		window.alert ("Please enter the content！")
		document.search_form.search_key.focus();
		return false;  
	}
	
	if(document.search_form.type.value == "5")
	{
		//文件搜索
		document.search_form.action=root_url+"modules/file_list.php";
		document.search_form.submit();
	}else
	{
		//文章搜索
		document.search_form.action=root_url+"modules/article_list.php";
		document.search_form.submit();
	}
	return true;
}


function reply_check()
{
	if(document.reply_form.reply_title.value == "")
	{
		window.alert ("Please enter the title！")
		document.reply_form.reply_title.focus();
		return false;  
	}
	
	if(document.reply_form.reply_user_name.value == "")
	{
		window.alert ("Please enter the user name！")
		document.reply_form.reply_user_name.focus();
		return false;  
	}
	
	if(document.reply_form.reply_content.value == "")
	{
		window.alert ("Please enter the content！")
		document.reply_form.reply_content.focus();
		return false;  
	}
	if (document.reply_form.vcode.value == "")
	{
		window.alert ("Please enter the authentication code！")
		document.reply_form.vcode.focus();
		return false;
	}
	return true;
}

function advice_check()
{
	if(document.action_form.ad_company.value == "")
	{
		window.alert ("Please enter your company！")
		document.action_form.ad_company.focus();
		return false;  
	}
	if(document.action_form.ad_mail.value == "")
	{
		window.alert ("Please enter your E-mail！")
		document.action_form.ad_mail.focus();
		return false;  
	}
	
	if(document.action_form.ad_phone.value == "")
	{
		window.alert ("Please enter your phone！")
		document.action_form.ad_phone.focus();
		return false;  
	}	

	if(document.action_form.ad_content.value == "")
	{
		window.alert ("Please enter the comments！")
		document.action_form.ad_content.focus();
		return false;  
	}

	return true;
}


