﻿//检查是否正确Email
function checkEmailA(_input,_err) {
    var flag1 = true;
    var input = document.getElementById(_input);
    var re = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}(\.([a-z]|[A-Z]){2})?$/gi;
    //var re = new RegExp("/^([a-z]|[A-Z]|[0-9]|\.|-|_)+@([a-z]|[A-Z]|[0-9]|-|_)+\.([a-z]|[A-Z]){2,4}(\.([a-z]|[A-Z]){2})?$/", "gi");
    if (!re.test(input.value)) {
        alert(_err);
	    input.focus();
        flag1 = false;
    }
    return flag1;
}
//检查文本框是否为空
function chkNull(_input,_err)
{
	var flag1 = true;
	var txt=document.getElementById(_input);
  if(txt.value=="")
  {
    alert(_err);
	txt.focus();
	flag1=false;
	}
	return flag1;
}

//用户登录
function chkLogin() {
    var txtUs = document.getElementById("txtUsername");
    var txtPw = document.getElementById("txtPassword");
    var divu = document.getElementById("divU");
    var divp = document.getElementById("divP");
  //if(!chkNull("txtCode","请"))
    //return false;
    if (txtUs.value=="") {
        divu.innerHTML = checkAlert+"<div style='float:left;height:20px;'>请输入姓名</div>";
        txtUs.focus();
        return false;
    }
    //else if (!checkEmail("txtUsername", "divU", "请输入正确的邮箱地址")) {
            //return false;
    //}


    if (txtPw.value < 1) {
        divp.innerHTML = checkAlert + "<div style='float:left;'>请输入密码</div>";
        txtPw.focus();
        return false;
    }
divu.innerHTML = checkOk;
divp.innerHTML = checkOk;
}
//首页用户登录
function chkLogindex() {
    var txtUs = document.getElementById("txtUname");
    var txtPw = document.getElementById("txtPwd");
    if (txtUs.value=="") {
        alert("请输入姓名");
        txtUs.focus();
        return false;
    }
    if (txtPw.value < 1) {
        alert("请输入密码");
        txtPw.focus();
        return false;
    }
}
//订车
function chkOrder() {
    var txtUs = document.getElementById("txtAreaS");
    var txtPw = document.getElementById("txtAreaE");
    if (txtUs.value == "") {
        alert("请输入订车地点");
        txtUs.focus();
        return false;
    }
    if (txtPw.value < 1) {
        alert("请输入还车地点");
        txtPw.focus();
        return false;
    }
}
//用户登录

//留言
function chkMsg()
{
	if(!chkNull("txtTitle","请输入标题"))
	    return false;
	if (!chkNull("txtContent", "请输入标题"))
	    return false;
	return true;
}

//注册
function chkReg() {
    if (!chkNull("txtUsername", "请输入姓名"))
        return false;

    if (!chkNull("txtPassword", "请输入密码"))
        return false;
    if (!chkNull("txtPasswordre", "请输入重复密码"))
        return false;
    var txtPwd = document.getElementById("txtPassword");
    var txtPwdRe = document.getElementById("txtPasswordre");
    if (txtPwd.value != txtPwdRe.value) {
        alert("重复密码和密码输入不一致，请重输");
        txtPwdRe.focus();
        return false;
    }
    if (!chkNull("txtCompany", "请输入公司/机构"))
        return false;
    if (!chkNull("txtPosition", "请输入职位"))
        return false;
    if (!chkNull("txtTel", "请输入电话/传真"))
        return false;
    if (!chkNull("txtEmail", "请输入邮箱地址"))
        return false;
    if (!checkEmailA("txtEmail", "请输入正确的邮箱地址"))
        return false;

    if (!chkNull("txtAdd", "请输入地址"))
        return false;
    
    if (!chkNull("txtMobile", "请输入手机"))
        return false;
    if (!chkNull("txtIdCard", "请输入身份证号"))
        return false;
    //if (!chkNull("txtReporter", "请输入记者证号"))
        //return false;
    //if(!chkNull("txtFax","请输入传真"))
    //return false;
    if (!chkNull("txtQuestions", "请输入问题"))
        return false;
    if (!chkNull("txtAnswer", "请输入答案"))
        return false;
    if (!chkNull("txtCode", "请输入验证码"))
        return false;
    return true;
}
//企业注册
function chkComReg() {
    if (!chkNull("txtUsername", "请输入姓名"))
        return false;
    if (!chkNull("txtCompany", "请输入公司/机构"))
        return false;
    if (!chkNull("txtPosition", "请输入职位"))
        return false;
    if (!chkNull("txtTel", "请输入电话/传真"))
        return false;
    if (!chkNull("txtEmail", "请输入邮箱地址"))
        return false;
    if (!checkEmailA("txtEmail", "请输入正确的邮箱地址"))
        return false;

    if (!chkNull("txtAdd", "请输入地址"))
        return false;

    if (!chkNull("txtMobile", "请输入手机"))
        return false;
    if (!chkNull("txtIdCard", "请输入身份证号"))
        return false;
    if (!chkNull("txtCode", "请输入验证码"))
        return false;
    return true;
}
//修改密码
function chkModpass() {
    if (!chkNull("txtOpass", "请输入原始密码"))
        return false;
    if (!chkNull("txtNpass", "请输入新密码"))
        return false;
    if (!chkNull("txtRpass", "请输入重复密码"))
        return false;
    var txtPwd = document.getElementById("txtNpass");
    var txtPwdRe = document.getElementById("txtRpass");
    if (txtPwd.value != txtPwdRe.value) {
        alert("重复密码和新密码输入不一致，请重输");
        txtPwdRe.focus();
        return false;
    }
    return true;
}
//非会员资料
function chkNomem()
{
	if(!chkNull("txtName","请输入姓名"))
	    return false;
	if (!chkNull("txtComName", "请输入公司名称"))
	    return false;
	if(!chkNull("txtAdd","请输入地址"))
	  return false;
	if(!chkNull("txtTel","请输入电话"))
	    return false;
	if (!chkNull("txtMobile", "请输入手机"))
	    return false;
	if (!chkNull("txtEmail", "请输入邮箱"))
	    return false;
	if (!checkEmailA("txtEmail", "请输入正确的邮箱地址"))
	    return false;
	return true;
}
//修改会员信息
function chkMemMod()
{
    if (!chkNull("txtAdd", "请输入地址"))
        return false;
    if (!chkNull("txtTel", "请输入电话"))
        return false;
    if (!chkNull("txtMobile", "请输入手机"))
        return false;
    if (!chkNull("txtFax", "请输入传真"))
        return false;
    if (!chkNull("txtQuestions", "请输入问题"))
        return false;
    if (!chkNull("txtAnswer", "请输入答案"))
        return false;
    if (!chkNull("txtCode", "请输入验证码"))
        return false;
	return true;
}

//找回密码
function chkFpwd()
{
	if(!chkNull("txtUsername","请输入姓名"))
	  return false;
	//if(!checkEmailA("txtUsername","请输入正确的邮件地址"))
	  //return false;if (!chkNull("txtQuestion", "请输入您的问题"))
	  return false;
	if(!chkNull("txtAnswer","请输入答案"))
	    return false;
	if (!chkNull("txtPassword", "请输入密码"))
	    return false;
	if (!chkNull("txtPasswordre", "请输入重复密码"))
	    return false;
	var txtPwd = document.getElementById("txtPassword");
	var txtPwdRe = document.getElementById("txtPasswordre");
	if (txtPwd.value != txtPwdRe.value) {
	    alert("重复密码和密码输入不一致，请重输");
	    txtPwdRe.focus();
	    return false;
	}
	if(!chkNull("txtCode","请输入验证码"))
	  return false;
	return true;
}

 var change=function(e)
 {
   document.getElementById('random_img').src='../managecenter/randomImg.aspx?a='+Math.random();
 };
