Tag:jquery Verification code SMS countdown
Send SMS Verification Code $ (": Button.getcode"). Click (function () {var reg =/^ ((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1})) +\D{8}) $/; if (!reg.test ($ ("#mobile"). Val ())) {$ (' #profile. Error_mobile '). CSS (' Display ', ' inline '); return false; }else{$ (' #profile. Error_mobile '). Hide (); } var countdown = 60; var _this = $ (this); Set button effect to start timing _this.attr ("Disabled", "true"); _this.val (Countdown + "re-acquired after second"); Start timer, 1 seconds to execute var timer = setinterval (function () {if (countdown = = 0) { Clearinterval (timer);//Stop Timer _this.removeattr ("disabled");//Enable button _this.val ("Resend Verification Code"); } else {countdown--; _this.val (Countdown + "re-acquired after second"); }}, 1000); $.ajax ({type: ' POST ', url: ' <%=path%>/user/sendcaptchas ', DataType: ' JSON ', Data:{' Stype ': ' 3 ', ' CType ': ' 1 ', ' Mobile ': $ ("#mobile"). Val ()}, Success:function (data) {if (Data.errori nfo.errorcode== ') {/* alert ("message sent successfully"); */}else{alert (data.errorinf O.errorcode); } } }); return false; });
<input class="GetCode"Type="Button"Value="FreeSend Verification Code"/>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JQuery implementation of the Click button after the countdown effect, more for the implementation of mobile phone verification Code, email Verification Code