sendsms.js 1.5 KB

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