This article mainly introduces jquery's countdown code for sending verification codes on mobile phones. For more information, see
The Code is as follows:
Var wait = 60; // time
Function time (o, p) {// o is the button object, p is optional, here is 60 seconds later, prompting text changes
If (wait = 0 ){
O. removeAttr ("disabled ");
O. val ("click to send verification code"); // change the value of the value in the button
P.html ("If you do not receive the verification code within 1 minute, please check whether your mobile phone number is correct or resend ");
Wait = 60;
} Else {
O. attr ("disabled", true); // do not click the button during the countdown
O. val (wait + "get verification code again in seconds"); // change the value of the value in the button
Wait --;
SetTimeout (function (){
Time (o, p); // call cyclically
},
1000)
}
}
View:
The Code is as follows:
Call:
The Code is as follows:
Echo CHtml: ajaxSubmitButton ('click to send verification code ',
CHtml: normalizeUrl (
Array ('/ajax/sendGetPassMobilCaptcha', 'zm _ id' => $ model-> zm_id)
),
Array ('success' => 'function (result ){
If (result = 1 ){
$ (". Ys_98" ).html ("the verification code is successfully sent. Please check your mobile phone in time. ");
Time ($ ("# yt0"), $ (". ys_98 "))
} Else {
$ (". Ys_98" ).html ("Verification Code failed to be sent. Please try again or contact the administrator. ");
}
} ', 'Data' => "zm_id = ". $ model-> zm_id. "& zm_mob = ". $ model-> zm_mob. "& zm_name = ". $ model-> zm_name
),
Array ('class' => 'mem _ btn mem_btn26 '));