jquery implementation of the phone to send verification code countdown code _jquery

Source: Internet
Author: User

Copy Code code as follows:

var wait=60;//time
function Time (o,p) {//o is the object of the button, p is optional, here is 60 seconds later, prompt text changes
if (wait = = 0) {
O.removeattr ("Disabled");
O.val ("Click Send Verification Code");/change the value of the button
P.html ("If you do not receive the verification code within 1 minutes, please check that your mobile phone number is correct or resend");
wait = 60;
} else {
O.attr ("Disabled", true)//No click button during countdown
O.val (wait + seconds to retrieve verification code);/Change the value of the button
wait--;
settimeout (function () {
Time (o,p);//Loop call
},
1000)
}
}

View:
Copy Code code as follows:

<input class= "mem_btn mem_btn26" type= "Submit" Name= "Yt0" value= "Click Send Authentication Code" id= "BTN" >

Call:
Copy Code code 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 ("Authentication code send 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 '));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.