首先必须引用JQ库 jquery.min.js 下面就是上代码  其余怎么传怎么收 和短信接口就很简单搞定了 下面代码其实还有很多缺陷 就凑活用

$(document).ready(function(){
    $("#Submit").click(
                       function get_mobile(){
   
var mob1=$("#mobile").val();
if(mob1 !='' && mob1.length==11){
       var mcode=Math.round(Math.random()*10000);
    $.get("mess.php?mobile="+$("#mobile").val()+"&mcode="+mcode,function(data){
//      alert(data);
  
    });
   
 //  window.alert($("#mobile").val());
         }else{
                          
                           window.alert('您的手机号码为空或者不是11位手机号');
                          
                           }

 
    });
   
   
 
var test = {
       node:null,
       count:60,
       start:function(){
          //console.log(this.count);
          if(this.count > 0){
             this.node.value = this.count--;
             var _this = this;
             setTimeout(function(){
                _this.start();
             },1000);
          }else{
             this.node.removeAttribute("disabled");
             this.node.value = "再次发送";
             this.count = 60;
          }
       },
       //初始化
       init:function(node){
          this.node = node;
          this.node.setAttribute("disabled",true);
          this.start();
       }
      
      
      
    };
   
   
                     
   
    var btn = document.getElementById("Submit");
    btn.onclick = function(){
        var mob1=$("#mobile").val();
        if(mob1 !='' && mob1.length==11){ 
       alert("验证信息会发送到"+$("#mobile").val());
       test.init(btn);
        }
    };
   
  });

 <li><span class="a">请输入用户手机号</span><span class="b"> <p>手机号:<input type="text" name="mobile" value="" id="mobile" onBlur="check_mobile(this.value)"/><input type="button" value="获取验证码" id="Submit"><span id="mobile_notice"></span></p>
  <p>验证码:<input type="text" name="code" value="" id="code"/></p></span></li>

发表回复