【js与jquery】订单提交页发送短信功能

来源:互联网 发布:手机开核软件 编辑:程序博客网 时间:2024/06/06 00:59

【js与jquery】订单提交页发送短信功能

分类: 【jquery深入研究】 1632人阅读 评论(0)收藏 举报
jqueryfunction手机mobileclasssms

1.效果如图所示:


2.html代码:

[php] view plaincopy
  1. <div class="indFpho" >  
  2.     <p>手机号码:</p>  
  3.     <p>  
  4.         <input type="text" name="telphone" id="telphone" value="{$order_info.consignee_mobile}" />  
  5.     </p>  
  6.     <p class="timeT">  
  7.         <input type="button" id="submitPhone" value="发送到手机">  
  8.     </p>  
  9.       <font id="submitPhone_info">已发送,1分钟后可重新获取</font>  
  10.       <font id="telphone_info" color="red">手机号格式不正确 !</font>        
  11. </div>  

3.jquery代码:
[php] view plaincopy
  1. $(function(){  
  2.     $('#submitPhone').bind('click',submit_success);  
  3.     $("#telphone").blur(function(){  
  4.         //获取手机号,并去除左右两边空格  
  5.         var telphone=$.trim($("#telphone").val());  
  6.         if(is_mobile(telphone)){  
  7.             $("#telphone_info").html("");  
  8.         }else{  
  9.             $("#telphone_info").html("手机号码格式不正确");  
  10.         return false;  
  11.         }   
  12.     });  
  13. })  
  14.   
  15. //订单提交页-验证手机号  
  16. function is_mobile(mobile) {  
  17.     if( mobile == "") {  
  18.         return false;  
  19.     } else {  
  20.         if( ! /^0{0,1}(13[0-9]|15[0-9]|18[0-9]|14[0-9])[0-9]{8}$/.test(mobile) ) {  
  21.             return false;  
  22.         }  
  23.         return true;  
  24.     }  
  25. }   
  26.   
  27. //验证手机号码  
  28. function checkMobile(){  
  29.     var sMobile = document.getElementById('telphone').value;  
  30.     if(!(/^1[3|4|5|8][0-9]\d{8}$/.test(sMobile))){  
  31.         popAlert("请输入正确的手机号码");  
  32.         return false;  
  33.     }else{  
  34.         return true;  
  35.     }  
  36. }  
  37.   
  38. //60秒后重新获取  
  39. var time=60;  
  40. function submit_success(){  
  41.     if(checkMobile()){//判断手机号格式是否正确  
  42.         $("#submitPhone_info").html('已发送,1分钟后可重新获取');  
  43.         //发送短信  
  44.         $.post("/index.php?c=goods&a=send_sms",{oid:$("#oid_info").val(),bank_radio:$('input:radio[name="bank_radio"]:checked').val(),telphone:$.trim($("#telphone").val())},function(data){//返回值  
  45.             //根据订单号、手机号及选择的银行来异步发送不同的短信到用户手机  
  46.         });  
  47.           
  48.         $('#submitPhone').html(function timeends(){       
  49.             if( time < 0){     
  50.                 time=60;                  
  51.                 document.getElementById("submitPhone").disabled=false;  
  52.                 document.getElementById("submitPhone").value="重新获取";  
  53.                 $("#submitPhone_info").html('');  
  54.             }else{    
  55.                 document.getElementById("submitPhone").disabled=true;  
  56.                 document.getElementById("submitPhone").value="重新获取("+time+")";  
  57.                 $("#submitPhone_info").html('已发送,1分钟后可重新获取');  
  58.                 time--;  
  59.                 a=setTimeout(timeends,1000);  
  60.             }  
  61.         });   
  62.         return true;  
  63.     }else{//如果不是正确的手机号,则返回false  
  64.         return false;  
  65.     }     

http://blog.csdn.net/yanhui_wei/article/details/7936642

0 0