Home > Web Front-end > JS Tutorial > body text

jquery implements countdown code for mobile phones to send verification codes_jquery

WBOY
Release: 2016-05-16 17:00:14
Original
1139 people have browsed it

Copy code The code is as follows:

var wait=60;//time
function time(o,p) {//o is the object of the button, p is optional, here is the change of the prompt text after 60 seconds
if (wait == 0) {
o.removeAttr("disabled ");
o.val("Click to send verification code");//Change the value of value in the button
p.html("If you do not receive the verification code within 1 minute, please check that you filled in Is the mobile phone number correct or resend?");
wait = 60;
} else {
o.attr("disabled", true);//It is forbidden to click the button during the countdown
o .val(wait "Re-obtain the verification code after seconds");//Change the value of the button
wait--;
setTimeout(function() {
time(o,p);// Loop call
},
1000)
}
}

View:
Copy code The code is as follows:



Call:
Copy code 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("Verification code sent successfully, Please check your phone in time. ");
time($("#yt0"),$(".ys_98"))
}else{
$(".ys_98").html( "The 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'));
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!