Jquery countdown code for sending verification codes on mobile phones

Source: Internet
Author: User

Jquery countdown code for sending verification codes on mobile phones

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:

<Input class = "mem_btn mem_btn26" type = "submit" name = "yt0" value = "click to send a verification code" id = "btn">

 

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 '));

 

 

Related Article

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.