"18th" mobile phone verification Code

Source: Internet
Author: User

Nonsense not much to say, directly on the code.

                <Divclass= "Form-group has-feedback">                    <Divclass= "Input-group">                        <inputtype= "text"class= "Form-control input-large"name= "Phone"ID= "Phone"placeholder= "Please enter your phone number">                        <spanclass= "Input-group-btn">                            <Buttonclass= "Btn btn-info"style=""type= "button"onclick= "SendMessage ()">Send Verification Code</Button>                        </span>                    </Div>                </Div>                <Divclass= "Form-group has-feedback">                    <Divclass= "Input-append">                        <inputtype= "text"class= "Form-control span2"placeholder= "Verification Code"name= "Code"onfocus= "Checkphone ()" />                        <spanclass= "Add-on"ID= "MSG"></span>                    </Div>                </Div>
        varIntervalobj;//timer variable, control time        varCount = 60;//interval function, 1 second execution        varCurcount;//current number of seconds remaining        varCode = "";//Verification Code        varCodelength = 6;//Verification Code Length        functionSendMessage () {if(Checkinput ()) {Curcount=count;  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 enter the verification code in" + Curcount + "seconds)); Intervalobj= Window.setinterval (setremaintime, 1000);//start Timer, execute once in 1 seconds                //send processing data to the background                varPostData ={code:code, Phone: $ ("#phone"). Val ()} $.ajax ({type:"POST",//transfer by postDataType: "Text",//data format: JSONURL: '/account/yanzheng ',//Destination Addressdata:postdata, Error:function(XMLHttpRequest, Textstatus, Errorthrown) {}, Success:function(msg) {if(msg = = "0") {layer.msg ("Verification code sent successfully!" "); } Else if(msg = = "-1") {layer.msg ("Verification code failed to send!" "); 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                        }                    }                }); }        }        //Timer handler function        functionSetremaintime () {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{Curcount--; $("#btnSendCode"). Val ("Please enter the verification code in" + Curcount + "seconds)); }        }
         PublicActionResult Yanzheng () {stringPhone = request["Phone"]; stringCode = request["Code"]; StringBuilder SMS=NewStringBuilder (); Sms. AppendFormat ("name={0}","");//User AccountSms. AppendFormat ("&pwd={0}","");//Landing Platform, Management center-basic Information-Interface password (28-bit ciphertext), copy and use. Sms. AppendFormat ("&content={0}","Hello, thank you for logging in, you get the verification code is:"+ Code);//Send contentSms. AppendFormat ("&mobile={0}", Phone);//Mobile phone Number (multiple use, separate)Sms. AppendFormat ("&sign={0}","");//the abbreviation of the company or the abbreviation of the product can be (user signature: can be omitted)Sms. Append ("&type=pt"); stringRESP = pc. Pushtoweb ("http://.com/asmx/smsservice.aspx", SMS.            ToString (), Encoding.UTF8); string[] msg = resp. Split (','); if(msg[0] =="0") {session["Phonecode"] =Code; //return Content ("Submit success: Sendid=" + msg[1]);                returnContent ("0"); }            Else            {                //return Content ("Commit failed: Error message =" + msg[1]);                returnContent ("-1"); }        }

---------------------------------------------------------------------------------------------------------

Reprint please remember the author and source Oh-.-
Kingdudu
Original source: http://www.cnblogs.com/kingdudu/p/4946878.html

---------------------------------------------------------------------------------------------------------

"18th" mobile phone verification Code

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.