// JavaScript Document
function UserPostSave(){
var message;
message=getFormValues(document.getElementsByTagName("form")[1]);
load("UserPostSave.asp?"+message);
}
function getFormValues(fobj){
var str='';
for(var i=0;i<fobj.elements.length;i++){
str+=fobj.elements[i].name+'='+escape(fobj.elements[i].value)+'&';
}
str=str.substr(0,(str.length-1));
return str;
}
function CheckMyReg(){
  if(myform.UserName.value==''){
   alert("用户名不能为空");
   myform.UserName.focus();
   return false;
  }
    if(myform.UserName.value.length<4){
   alert("帐号最少4位,请重新填写!");
   myform.UserName.focus();
   return false;
  }
  if(myform.Password.value==''){
  alert("密码不能为空");
  myform.Password.focus();
  return false;
  }
  if(myform.Password.value!=myform.Password1.value){
  alert("两次密码不一样");
  myform.Password.focus();
  return false;
  }
  if(myform.Question.value==''){
  alert("密码问题不能为空");
  myform.Question.focus();
  return false;
  }
  if(myform.Answer.value==''){
  alert("问题答案不能为空");
  myform.Answer.focus();
  return false;
  }
  if(myform.Somane.value==''){
  alert("姓名不能为空");
  myform.Somane.focus();
  return false;
  }
  if(myform.Email.value==''){
  alert("Email地址不能为空");
  myform.Email.focus();
  return false;
  } 
  
  var objv = myform.Email.value;
  var pattern = /[^@]+@([a-zA-Z0-9-]+.)+([a-zA-Z0-9-]{2}|net|com|gov|mil|org|edu|int)$/;
  flag = pattern.test(objv);
  if(!flag)
  {
   alert( "请留下正确的Email地址！");
   Email.focus();
   return false;
   }
   
   
   
   
   
   
   
   
  if(myform.Phone.value==''){
  alert("联系电话不能为空");
  myform.Phone.focus();
  return false;
  }
  if(myform.Add.value==''){
  alert("地址不能为空");
  myform.Add.focus();
  return false;
  }
  UserPostSave();
}
function responsewrite(text)
{
 if(text.indexOf("||")!=-1){
 document.all.show1.style.display="none";
 document.all.show2.style.display="";
 document.getElementById("show2").innerText = text.substring(0,text.length-2);
 }
 else{
 document.getElementById("errmessage").innerText = text;
  }
 //alert(text);
}

 function checkname(){
  var username=document.getElementById("UserName").value;
  if(username==''){
     alert("请输入用户名");
	 return false;
  }
 load("checkname.asp?username="+escape(username));
 }

 function checkguestbook(form){
 if(form.txt_subject.value==''){
   alert("标题不能为空");
   form.txt_subject.focus();
   return false;
 }
 if(form.txt_content.value==''){
   alert("内容不能为空");
   form.txt_content.focus();
   return false;
 }
 return true;
 }
 function checkmydata(myform){
   if(myform.txt_question.value==''){
     alert("密码问题不能为空");
	 myform.txt_question.focus();
	 return false;
   }
   if(myform.txt_email.value==''){
     alert("email不能为空");
	 myform.txt_email.focus();
	 return false;
   }
   var pattern = /[^@]+@([a-zA-Z0-9-]+.)+([a-zA-Z0-9-]{2}|net|com|gov|mil|org|edu|int)$/;
   if(!pattern.test(myform.txt_email.value)){
     alert("email格式有误");
	 myform.txt_email.focus();
	 return false;
   }
   if(myform.txt_comane.value==''){
     alert("公司名称不能为空");
	 myform.txt_comane.focus();
	 return false;
   }
   if(myform.txt_add.value==''){
     alert("地址不能为空");
	 myform.txt_add.focus();
	 return false;
   }
   if(myform.txt_somane.value==''){
     alert("姓名不能为空");
	 myform.txt_somane.focus();
	 return false;
   }
   if(myform.txt_phone.value==''){
     alert("联系电话不能为空");
	 myform.txt_phone.focus();
	 return false;
   }
   
 }
 function checkusername(form){
  if(form.txt_username.value==""){
   alert("用户名不能为空");
   form.txt_username.focus();
   return false;
  }
  if(form.txt_password.value==""){
   alert("密码不能为了空");
   form.txt_password.focus();
   return false;
  }
  return true;
 }

