<script language="javascript">
         
function checkEmail(){
    var email=document.getElementById("txtEmail").value;
    email.replace(/(^\s*)|(\s*$)/g, "");/*去两边空格*/
if(isNull(email)){
alert("电子邮箱不能为空!");
document.getElementById("txtEmail").focus();//光标定位
document.getElementById("txtEmail").value="";//清空
return false;//不提交表单
}
if(!isEmail(email)){
alert("电子邮箱非法!格式为[email protected]");
return false;//不提交表单
}else
    return true;
}
    function checkUserName(){
var name=document.getElementById("txtName").value;
    name.replace(/(^\s*)|(\s*$)/g, "");/*去两边空格*/
if(isNull(name)){
alert("会员名不能为空!");
return false;//不提交表单
}
if(!isOrLetter(name)){
alert("会员名格式有误!");
document.getElementById("txtName").focus();//光标定位
document.getElementById("txtName").value="";//清空
return false;//不提交表单
}
if(name.length<6){
alert("会员名长度有误,至少6位!");
document.getElementById("txtName").focus();//光标定位
document.getElementById("txtName").value="";//清空
    return false;//不提交表
}else
        return true;
}
function checkPassword(){
var password = document.getElementById("txtPassword").value;
password.replace(/(^\s*)|(\s*$)/g, "");/*去两边空格*/
if(isNull(password)){
alert("密码不能为空!");
document.getElementById("txtPassword").focus();//光标定位
    document.getElementById("txtPassword").value="";//清空
return false;//不提交表单
}
if(password.length<6){
alert("密码长度有误,至少6位!");
document.getElementById("txtPassword").focus();//光标定位
document.getElementById("txtPassword").value="";//清空
return false;//不提交表
}else
    return true;
}
function checkAffirmPassword(){
  var password = document.getElementById("txtPassword").value;
  var affirmPassword = document.getElementById("txtAffirmPassword").value;
 if(affirmPassword!=password){
 alert("两个密码不一致!");
         document.getElementById("txtPassword").focus();//光标定位
         document.getElementById("txtPassword").value="";//清空
         document.getElementById("txtAffirmPassword").value="";//清空
 return false; 
 }else
         return true;
}
         function isNull(str){
 if(str=="") return true;
 var regu = "^[ ]+$";
 var re = new RegExp(regu);
 return re.test(str);
}
      function isEmail(strEmail) {
             //var emailReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
             var emailReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
         if(emailReg.test(strEmail) )
             return true;
             else
             return false;
}
function isOrLetter( s ){//判断是否是字母
            var regu = "^[a-zA-Z].*$";  
            var re = new RegExp(regu);
        if (re.test(s)) 
            return true;
else
            return false;
}
   function validatefrom(){
if(checkEmail()&&checkUserName()&&checkPassword()&&checkAffirmPassword())
    return true;
else
return false;
}
</script>