jquery post 验证提交

180it 2020-04-25 PM 2939℃ 0条
 <script src="static/js/jquery-3.2.1.min.js"></script> 


<script>
$(document).ready(function(){
    $("#submitTel").click(function(){
        
 var tm_tel=$("#msg_userphone").val();
 var tm_name=$("#msg_username").val();
 var tm_xueli=$("input[name='name0']:checked").val();
 var tm_age=$("input[name='name1']:checked").val();
 var tm_yixiang=$("input[name='name2']:checked").val();
 
 /*
   if (!tm_xueli) {
                    alert("请选择学历");
                    return false;
                }
               
     if (!tm_age) {
                    alert("请选择年龄");
                    return false;
                } */
 
                if (!tm_name) {
                    alert("请填写您的姓名");
                    return false;
                }
                
                
                if (!tm_tel) {
                    alert("请填写您的手机号码");
                    return false;
                }
                var re2=/^[0-9]{11}$/;
                if(!(re2.test(tm_tel)))
                {
                    alert("电话只能为11位数字。"+tm_tel);
                    return false;
                }
                
        
        $.post("http://xxx.xxxx.com/post.asp",{
            tel:tm_tel,
            xingming:tm_name,
            xx1:tm_xueli+" "+tm_age+" "+tm_yixiang,
            cls : 15
        },
        function(data,status){
//alert("数据: " + data + "状态: " + status);
    
alert("您的测评信息已成功提交,我们将尽快安排老师联系您!");
window.location.reload();
        });
    });
});
</script>






<div class="module" style="height: 500px"> 
   <div class="selfTestForMsgRed" style="height: 500px"> 
    <div class="self-test "> 
     <h2 data="title" edit="text" style="font-size: 24px;" text="测一测您考取本科的通过率?"> 测一测考取本科要多久,多少钱? </h2> 
     <div class="line-wrap" data="subTitle" edit="switchText" text="" flag="1"> 
     </div> 
     <div class="testTag"> 
      <div class=" msgTag"> 
       <div class="text-con" data="questions-0-title" edit="text" style="font-size: 14px;color: rgba(0, 0, 0, 0.8);display: inline-block;" text="1. 您的最高学历是?">
         1. 您的最高学历是? 
        <span>*</span> 
       </div> 

       <div class="radio-wrap"> 
        <input type="radio" id="name0" name="name0" checked value="高中" /> 

        <label for="id-0-1" data="questions-0-answer-1" edit="textContent" text="高中"> 高中 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name0" name="name0" value="大专"/> 
        <label for="id-0-2" data="questions-0-answer-2" edit="textContent" text="大专"> 大专 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name0" name="name0" value="初中"/> 
        <label for="id-0-3" data="questions-0-answer-3" edit="textContent" text="初中"> 初中 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name0" name="name0" value="其他"/> 
        <label for="id-0-4" data="questions-0-answer-4" edit="textContent" text="其他"> 其他 </label> 
       </div> 
      </div> 
      <div class=" msgTag"> 
       <div class="text-con" data="questions-1-title" edit="text" style="font-size: 14px;color: rgba(0, 0, 0, 0.8);display: inline-block;" text="2. 您的年龄是?">
         2. 您的年龄是? 
        <span>*</span> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name1" name="name1" checked value="18-23岁"/> 
        <label for="id-1-0" data="questions-1-answer-0" edit="textContent" text="18-23岁"> 18-23岁 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name1" name="name1" value="24-30岁"/> 
        <label for="id-1-1" data="questions-1-answer-1" edit="textContent" text="24-30岁"> 24-30岁 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name1" name="name1" value="31-40岁"/> 
        <label for="id-1-2" data="questions-1-answer-2" edit="textContent" text="31-40岁"> 31-40岁 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name1" name="name1" value="其他"/> 
        <label for="id-1-3" data="questions-1-answer-3" edit="textContent" text="其他"> 其他 </label> 
       </div> 
      </div> 
      <div class=" msgTag"> 
       <div class="text-con" data="questions-2-title" edit="text" style="font-size: 14px;color: rgba(0, 0, 0, 0.8);display: inline-block;" text="3. 您的意向专业是?">
         3. 您的意向专业是? 
        <span>*</span> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name2" name="name2"  checked  value="管理类"/> 
        <label for="id-2-0" data="questions-2-answer-0" edit="textContent" text="管理类"> 管理类 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name2" name="name2"  value="财经类"/> 
        <label for="id-2-1" data="questions-2-answer-1" edit="textContent" text="财经类"> 财经类 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name2" name="name2" value="语言类"/> 
        <label for="id-2-2" data="questions-2-answer-2" edit="textContent" text="语言类"> 语言类 </label> 
       </div> 
       <div class="radio-wrap"> 
        <input type="radio" id="name2" name="name2"  value="其他"/> 
        <label for="id-2-3" data="questions-2-answer-3" edit="textContent" text="其他"> 其他 </label> 
       </div> 
      </div> 
     </div> 
      <p class="tel-reminde">请输入您的姓名<span>*</span></p>  
      <input class="telVlaue" id="msg_username" name="msg_username" placeholder="请输入您的姓名" data="inputPlaceholder" edit="textContent" text="请输入您的姓名" /> 
      <p class="tel-reminde">请输入您的手机号<span>*</span></p>  
     <input class="telVlaue" id="msg_userphone" name="msg_userphone" placeholder="请输入您的手机号" data="inputPlaceholder" edit="textContent" text="请输入您的手机号" /> 
     
     <a class="submitTel" data="bottomButton" edit="msgButton" style="font-size: 16px;color: rgb(255, 255, 255);background-color:rgb(248, 89, 89)" text="提交查看测试结果" id="submitTel" name="submitTel"> 提交查看测试结果 </a> 
     

     
    </div> 
   </div> 
  </div> 

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

jquery post 验证提交