sendsms2.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function sendmsgbutton(){
  2. if ($("#reg_mobile").hasClass("errinput") || $("#reg_mobile").val()=="") {
  3. alert("请输入手机号码");
  4. $("#reg_mobile").focus();
  5. return;
  6. }
  7. var aj = $.ajax( {
  8. url:'../sendsms.php',
  9. data:{ phonenum : $("#reg_mobile").val() },
  10. type:'post',
  11. cache:false,
  12. dataType:'json',
  13. success:function(data) {
  14. if($.trim(data) =="success" ){
  15. }else{
  16. }
  17. },
  18. error : function() {
  19. }
  20. });
  21. var test = {
  22. node:null,
  23. count:120,
  24. start:function(){
  25. if(this.count > 0){
  26. this.count--;
  27. this.node.value = this.count + "秒后可重新获取";
  28. var _this = this;
  29. setTimeout(function(){
  30. _this.start();
  31. },1000);
  32. }else{
  33. this.node.removeAttribute("disabled");
  34. this.node.setAttribute("class","disabled");
  35. this.node.value=("再次发送手机验证码");
  36. this.count = 120;
  37. }
  38. },
  39. //初始化
  40. init:function(node){
  41. this.node = node;
  42. this.node.setAttribute("disabled",true);
  43. this.node.setAttribute("class","disable");
  44. this.start();
  45. }
  46. };
  47. var btn = document.getElementById("sendmsg");
  48. test.init(btn);
  49. }