


document.write("<form action='http://www.chaomoli.com/shop/subscribe_check.php' method='post' name='frmSub1'  id='frmSub1' onsubmit='return valid(this)'>");
document.write("    <div align='center'></div>");
document.write("    <table width='100%' border='0' cellpadding='0' cellspacing='0'>");
document.write("      <tbody><tr>");
document.write("        <td>");
document.write("	<table width='100%' border='0' id='table1'>");
document.write("	  <tbody><tr align='left'>");
document.write("        <td width='22%' align='right'>称呼：</td>");
document.write("        <td width='78%'><input name='USERNAME' type='text' class='input' id='username' title='称呼不能为空' align='left' DType='y9'></td>");
document.write("     </tr>");
document.write("	    <tr align='left'>");
document.write("	      <td align='right'>&nbsp;</td>");
document.write("	      <td><span class=redFont>*(必填，形如张先生)</span></td>");
document.write("	      </tr>");
document.write("	    <tr align='left'>");
document.write("       <td align='right'>手机：</td>");
document.write("       <td><input name='MOBILEPHONE' type='text' class='input' id='leadphone' title='手机不能为空' align='left' DType='y9'></td>");
document.write("      </tr>	");
document.write("	  	    <tr align='left'>");
document.write("	  	      <td align='right'>&nbsp;</td>");
document.write("	  	      <td><span class='redFont'>*(必填，用于接收课程信息;郑重声明：不扣取任何手机费用)</span></td>");
document.write("	  	      </tr>");
document.write("    </tbody></table></td>");
document.write("      </tr>");
document.write("      <tr>");
document.write("        <td align='center'><input type='image' name='fm_submit'  src='images/btn.gif' id='fm_submit' value='点击这里提交报名'></td>");
document.write("      </tr>");
document.write("    </tbody></table>");
document.write("<input type='hidden' value='2' name='CAMID'>");
document.write("<input type='hidden' name='BONUSCODE'>");
document.write("</form>");


function valid(form1){
re=new RegExp("a=([^\&]*)","i");
a=re.exec( document.location.search);
if(a!=null){form1.BONUSCODE.value=a[1];};
return check(form1);
}



function check(form1)
{
//通用化表单校验函数!
var re=new Array();
re[1] = /^\w{3,20}$/;                                           //ID,不允许中文
re[2] = /^\d+$/ ;                                              //数值

re[3] = /^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/;
	
// /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;

//re[3] = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi                                     //Email
re[4] = /^.{2,30}$/                                           //普通,允许中文
re[5] = /^\d{6}$/                                              //邮政编码
re[6] = /^(00\d{1,3}-){0,1}0\d{3}-\d{7,8}$/                   //电话号码
re[7] = /^\d{4}$/                                        //4位验证码
re[8] = /(^\d{15}$)|(^\d{18}$)|(^\d{17}[Xx]$)/          //身份证
re[9] = /^(.|\n){1,}$/                                     //普通无最大限制,允许中文
re[10]= /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15\d{9}$/;//手机号码
//email地址
re[11]= /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;

var tem=0,i,j,x,y;    
for(i=0;i<form1.length;i++)
{
      var x = form1[i].getAttribute("DType");
      if (x != null){
            x = form1[i].getAttribute("DType").toUpperCase();
            y = parseInt(form1[i].getAttribute("DType").substr(1));
            switch(form1[i].type){
            case "text":
            case "textarea":
            case "password":
                  if(x.charAt(0)!='N'||form1[i].value.length>0){                      
                        if(y!=0){
                              if(form1[i].value.search(re[y])==-1){
                                    alert('错误提示\n\n【'+form1[i].title+"】");
                                    form1[i].focus();
                                    return false;
                                    }
                              if(form1[i].type=="password"&&form1[i+1].type=="password"&&form1[i].value!=form1[i+1].value){
                                    alert('两次输入的密码不一致,请重新输入');
                                    form1[i].focus();
                                    return false;
                                    }
                              }
                        }
                        break;
            case "select-one":if(y>1)y=1;
            case "select-multiple":
                  if(x.charAt(0)!='N'){
                        if(y!=0){tem=0;
                              for(j=0;j<form1[i].length;j++)
                                    {
                                    if(form1[i].options[j].selected)tem++;
                                    }
                              if(tem<y){
                                    alert(form1[i].title+'错误提示\n\n【你应该至少选择'+y+'项.】');
                                                form1[i].focus();
                                                return false;
                                    }
                        }
                  }
                  break;
            case "radio":if(y>1)y=1;
            case "checkbox":
                  if(x.charAt(0)!='N'){
                        if(y!=0){tem=0;
                              var radiotem=eval("form1."+form1[i].name);
                              for(j=0;j<radiotem.length;j++)
                                    if(radiotem[j].checked)tem++;
                                    }
                              if(tem<y){
                                    alert(form1[i].title+'错误提示\n你应该至少选择'+y+'项.');
                                                form1[i].focus();
                                                return false;
                                    }
                        }
                  break;
            }
      }
}
return true;
}

