Jquery mobile phone to send verification code countdown code
- 2020-03-30 01:42:58
- OfStack
var wait=60;// time
function time(o,p) {//O is the object of the button, and p is optional. Here is the change of the prompt after 60 seconds
if (wait == 0) {
o.removeAttr("disabled");
o.val(" Click send verification code ");//Change the value of value in the button
p.html(" If you are 1 The verification code was not received within minutes, please check whether the phone number you filled in is correct or resend ");
wait = 60;
} else {
o.attr("disabled", true);//Do not click the button during the countdown
o.val(wait + " Retrieve the captcha after seconds ");//Change the value of value in the button
wait--;
setTimeout(function() {
time(o,p);//Cycle call
},
1000)
}
}
View:
<input class="mem_btn mem_btn26" type="submit" name="yt0" value=" Click send verification code " id="btn">
Call:
echo CHtml::ajaxSubmitButton(' Click 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 was sent successfully, please check your mobile phone in time. ");
time($("#yt0"),$(".ys_98"))
}else{
$(".ys_98").html(" Verification code sent failed, 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'));