﻿ var GetData = function() {
           var obj=document.all.ddlType;
            var val=obj.selectedIndex;
           if(document.all.txtName.value=="")
            {
                alert("请输入姓名");
                document.all.txtName.focus();
                return false;
            }
             if(val==0)
            {
                  alert("请选择疾病类型");
                  return false;
            }
              if(document.all.txtEmail.value=="")
            {
                alert("请输入邮箱地址");
                document.all.txtEmail.focus();
                return false;
            }
            if(MailExpress()==false)
            {
                alert('请输入正确邮箱地址！格式为(XXX@126.com)');
                return false;
            }
             if(document.all.txtTel.value=="请输入联系电话或QQ号")
            {
                alert("请输入联系方式");
                document.all.txtTel.focus();
                return false;
            }
              if(document.all.txtTitle.value=="")
            {
                alert("请输入标题");
                document.all.txtTitle.focus();
                return false;
            }
                //js判断为空自己加一下
                var name = $('#txtName').val(); //获取值
                var tel = $('#txtTel').val();
                var email = $('#txtEmail').val();
                var title = $('#txtTitle').val();
                var type=$('#ddlType').val();
                var infor=$('#txtContent').val();
                 
                var paramsSerial = "name=" + escape(name) + "&tel="+tel+"&email="+email+"&type="+type+"&title="+escape(title)+"&infor="+escape(infor);

                //提交数据
                jQuery.ajax({
                    type: "POST",
                    url: "/question.aspx",
                    data:paramsSerial,
                    cache: false,
                    success: function(data) {
                       alert(data);
                       DoClear();
                       LoadValue();
                    },
                    error: function(data) {
                        alert(data);
                    }
                })
            
            
          
        }
        
        
        function MailExpress()
        {
            var email=document.all.txtEmail.value
            var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
            flag=pattern.test(email);
            if (flag)
            {return true;}
            else
               {
                return false;
                }

        }
        
        
        function DoClear()
        {
             document.all.txtName.value="";
             document.all.txtTel.value="";
             document.all.txtEmail.value="";
             document.all.txtTitle.value="";
             document.all.txtContent.value="";
             document.all.ddlType.selectedIndex=0;
             document.all.txtName.focus();
        }
        
        function ClearText()
        {
            document.getElementById("txtTel").value="";
            document.getElementById("txtTel").focus();
        }
        
        function LoadText()
        {
            if(document.getElementById("txtTel").value=="")
            {
                document.getElementById("txtTel").value="请输入联系电话或QQ号";
            }else
            {
                document.getElementById("txtTitle").focus();
            }
        }
        
        function LoadValue()
        {
                document.getElementById("txtTel").value="请输入联系电话或QQ号";
        }
        window.attachEvent("onload",LoadValue)
        
       