jquery realizes the countdown effect after clicking the button, it is used for sending the mobile phone verification code.

Source: Internet
Author: User

<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">"http://www.w3.org/1999/xhtml">"Scripts/jquery-2.1.1.min.js"Type="Text/javascript"></script> <script type="Text/javascript">varIntervalobj;//timer variable, control time        varCount = -;//interval function, 1 second execution        varCurcount;//current number of seconds remaining \        varCode ="";//Verification Code        varCodelength =6;//Verification Code Lengthfunction SendMessage () {Curcount=count; varDealtype = $ ("#phones"). Val ();//Mobile phone number            varUID = $ ("#uid"). Val ();//User uid//Generate verification Code             for(vari =0; i < codelength; i++) {Code+ = parseint (Math.random () *9). toString (); }            //Set button effect to start timing$("#btnSendCode"). attr ("Disabled","true"); $("#btnSendCode"). Val ("Please check the"+ Curcount +"Enter the verification code in seconds"); Intervalobj= Window.setinterval (Setremaintime, +);//start Timer, execute once in 1 seconds//send processing data to the background$.ajax ({type:"POST",//transfer by postDataType:"text",//data format: JSONUrl:'admins/index6',//Destination AddressData"dealtype="+ Dealtype +"&uid="+ UID +"&code="+Code, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {},//Error HandlingSuccess:function (msg) {}//return content            }); }          //Timer handler functionfunction Setremaintime () {if(Curcount = =0) {window.clearinterval (intervalobj);//Stop Timer$("#btnSendCode"). Removeattr ("Disabled");//Enable button$("#btnSendCode"). Val ("Resend Verification Code"); Code="";//clear the verification code. If you do not clear, after the time, the input received the verification code is still valid            }            Else {                //cooldown 60 seconds button to clickcurcount--; $("#btnSendCode"). Val ("Please check the"+ Curcount +"Enter the verification code in seconds"); }        }    </script> Verification Code"ImaCode2"Src="validcode.ashx"onclick="this.src= ' validcode.ashx?number= ' +math.random ()"/> <p> Mobile number: <input id="Phones"Type="text"Value=""/> </p> <P> user name: <input id="UID"Type="text"Value=""/> </P> <p><input id="Btnsendcode"Type="Button"Value="Send Verification Code"onclick="sendMessage ()"/></p></body>

The code under the controller

[HttpPost] PublicActionResult Index6 () {stringZH ="XXXXXXX";//SMS Interface Account            stringMM ="123456";//account Password            intSms_type = the;//channel numberstringDealtype = request["Dealtype"];//Phone number            stringUID = request["UID"];//User ID            stringCode = request["Code"];//Random Number
ContentstringNR ="Hello User:"+ UID +", your verification code is:"+Code+"Please enter as soon as possible!";
SMS interface channel address such as:stringURL ="http://www.6610086.net/jk.aspx?zh="+ ZH +"8&mm="+ mm +"&hm="+Dealtype+"&nr="+ NR +"&sms_type="+Sms_type; Response.Redirect (URL); //Response.Write ("<script>$.ajax" ({type: ' POST ', DataType: ' text ', url: "+ URL +", Data:null,error:function (XML HttpRequest, Textstatus, Errorthrown) {},success:function (msg) {}});</script> "); //Response.Write ("<script>$.ajax ([Type: ' POST ', DataType: ' text ',]);</script>"); returnView (); }

jquery realizes the countdown effect after clicking the button, it is used for sending the mobile phone verification code.

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.