Get captcha effects and background code

Source: Internet
Author: User

Client js+html Code

<script type= "Text/javascript" > var tcode = 0;//Timer return code//Get Verification Code function getverifycodeaction () {            var email = $ ("#email"). Val ();            if (!checkemail (email)) {$ ("#area_error"). AddClass ("Log-tips"). Show (). text (emailformatisfault);//Mailbox Format error                    } else {$.ajax ({type: "Post", Async:false,                    URL: "/handler/sendmsgtomail.ashx", data: {op:12, email:email},                        Success:function (Result) {var data = parseint (result); Switch (data) {Case 1: $ ("#area_error"). AddClass ("Log-tips"). Sh ow (). text (checkverifycode);//The verification code has been sent, please pay attention to check the $ ("#btnSendCode"). Removeattr ("onclick");//Remove Send verification code                The Click event Tcode = SetInterval ("Resend ()", 1000);//Set timer, 60 seconds after allowing to send again                Break                                Case-1: $ ("#area_error"). AddClass ("Log-tips"). Show (). text (fillemail);//Please enter your email                            Break                                Case-2: $ ("#area_error"). AddClass ("Log-tips"). Show (). text (mailnotreg);//Mailbox not registered                            Break                                Case-3: $ ("#area_error"). AddClass ("Log-tips"). Show (). text (operateexception);//Operation exception                            Break                                Case-4: $ ("#area_error"). AddClass ("Log-tips"). Show (). text (operateexception);//Operation exception                            Break                                Case-5: $ ("#area_error"). AddClass ("Log-tips"). Show (). text (onceminute);//can only be sent once per minute                            Break Default: $ ("#area_error"). ADDCLass ("Log-tips"). Show (). text (operateexception);//operation exception break;            }                    }                });        } return false;            }//Click to enter next function GoNext () {$ ("#area_error"). Removeclass ("Log-tips"). Text (""). Hide ();            var email = $ ("#email"). Val ();                if (!checkemail (email)) {$ ("#area_error"). AddClass ("Log-tips"). Show (). text (emailformatisfault);//mailbox format is incorrect            return false;            } var Vcode = $ ("#verify"). Val ();                if (Vcode = = "") {$ ("#area_error"). AddClass ("Log-tips"). Show (). text (fillverifycode);//Please enter a verification code            return false;                }//Determine if the verification code is correct $.ajax ({type: "post", url: "/handler/members.ashx", Data: {op:14, Email:email, Vcode:vcode}, Success:function (Result) {if (R        Esult = = "1") {                $ ("#area_error"). AddClass ("Log-tips"). Show (). text (vcodeisnotavailable);//Verification Code expired} if (result = = "1") {window.location = "forgot_password.aspx?email=" + Email + "&                    Vcode= "+ Vcode;        }                }            });            }//Timer function resend () {var wait60second= "60 seconds after re-send";            var totalcount = $ ("#hf_timecount"). Val ();            TotalCount = TotalCount-1;            $ ("#hf_timecount"). Val (TotalCount);            if (TotalCount = = 0) {resetsendmail ();            } else {$ ("#btnSendCode"). Text (Wait60second.replace ("TotalCount")); }        }
Reattach Send mailbox Event function Resetsendmail () {clearinterval (tcode); $ ("#hf_timecount"). Val ("60"); $ ("#btnSendCode"). Text ("Get Verification Code"); $ ("#btnSendCode"). attr ("onclick", "getverifycodeaction ()"); } </script>
<input id= hf_timecount "value=" type= "hidden"/>
<input type= "text" name= "email" id= "email"/>
<button type= "button" id= "Btnsendcode" onclick= "Getverifycodeaction ()" > Get Verification Code </button>
<input type= "Text" name= "Verify" id= "Verify"/>
<input type= "button" id= "Btn_next" value= "Next" onclick= "GoNext ()"/>

  

Service-Side code:

<summary>//e-mail///</summary>//<param name= "context" ></param>            <returns></returns> public String SendMail (HttpContext context) {try {if (!string.                IsNullOrEmpty (Cookieshelper.getcookie ("Send_mail_limit")) {return "-5";//can only be sent once per minute } string email = context.                request["email"]; if (string. IsNullOrEmpty (email) | | ! Commonhelper.isvalidemail (email)) {return "-1";//value is null}/ /determine if the message exists in the BLL. Web.member bllmember = new BLL.                Web.member ();                int mailcount = bllmember.getcountbyemail (email);                Models.Web.Member Member = bllmember.getmodelbyemail (email);                if (Mailcount = = 0 | | member = = NULL) {return "-2";//does not exist} StrinG Vcode = Commonhelper.randcode (8);                Models.Web.VerifyCode model = new Models.Web.VerifyCode ();                Model.v_code = Vcode;                Model.v_createdate = DateTime.Now;                Model.v_enddate = DateTime.Now.AddHours (2);                Model.v_status = 0;                Model.v_email = email; Bll. Web.verifycode BLLVC = new BLL.                Web.verifycode ();                int no = Bllvc.append (model);                    if (No > 0) {string sendText = ""; String TempPath = context.                    Server.MapPath ("~/emailtemp/modifypwd.txt"); using (StreamReader sr = new StreamReader (TempPath)) {SendText = Sr.                    ReadToEnd (); } SendText = Sendtext.replace ("{username_ch}", member.                    Persnalname); SendText = Sendtext.replace ("{username_en}", member.                    Persnalname); SendText = Sendtext.replace("{Vcode}", Vcode);                    Commonhelper.sendemail (email, sendText, Resource.Lang.RetrievePassword);                Cookieshelper.setcookie ("Send_mail_limit", "SendMail", 1.00);                } else {return "-3";//verification code generated an exception, please try again!            } return "1";//Success} catch (Exception) {return "-4";//exception }        }

  

Get captcha effects and background 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.