인증 코드 효과와 백엔드 코드 가져오기
<script type="text/javascript">
var tcode = 0;//
//
function GetVerifyCodeAction() {
var email = $("#email").val();
if (!checkEmail(email)) {
$("#area_error").addClass("log-tips").show().text(EmailFormatIsFault);//
}
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").show().text(CheckVerifyCode);// ,
$("#btnSendCode").removeAttr("onclick");// click
tcode = setInterval("ReSend()", 1000);// ,60
break;
case -1:
$("#area_error").addClass("log-tips").show().text(FillEmail);//
break;
case -2:
$("#area_error").addClass("log-tips").show().text(MailNotReg);//
break;
case -3:
$("#area_error").addClass("log-tips").show().text(OperateException);//
break;
case -4:
$("#area_error").addClass("log-tips").show().text(OperateException);//
break;
case -5:
$("#area_error").addClass("log-tips").show().text(OnceMinute);//
break;
default:
$("#area_error").addClass("log-tips").show().text(OperateException);//
break;
}
}
});
}
return false;
}
//
function GoNext() {
$("#area_error").removeClass("log-tips").text("").hide();
var email = $("#email").val();
if (!checkEmail(email)) {
$("#area_error").addClass("log-tips").show().text(EmailFormatIsFault);//
return false;
}
var vcode = $("#verify").val();
if (vcode == "") {
$("#area_error").addClass("log-tips").show().text(FillVerifyCode);//
return false;
}
//
$.ajax({
type: "post",
url: "/Handler/Members.ashx",
data: { op: 14, email: email, vcode: vcode },
success: function (result) {
if (result == "-1") {
$("#area_error").addClass("log-tips").show().text(VCodeIsNotAvailable);//
}
if (result == "1") {
window.location = "forgot_password.aspx?email=" + email + "&vcode=" + vcode;
}
}
});
}
//
function ReSend() {
var Wait60Second="60 ";
var TotalCount = $("#hf_timecount").val();
TotalCount = TotalCount - 1;
$("#hf_timecount").val(TotalCount);
if (TotalCount == 0) {
ReSetSendMail();
}
else {
$("#btnSendCode").text(Wait60Second.replace("60", TotalCount));
}
}
//
function ReSetSendMail() {
clearInterval(tcode);
$("#hf_timecount").val("60");
$("#btnSendCode").text(" ");
$("#btnSendCode").attr("onclick", "GetVerifyCodeAction()");
}
</script>
<input id="hf_timecount" value="60" type="hidden" />
<input type="text" name="email" id="email" />
<button type="button" id="btnSendCode" onclick="GetVerifyCodeAction()"> </button>
<input type="text" name="verify" id="verify" />
<input type="button" id="btn_next" value=" " onclick="GoNext()"/>
서버 코드:
/// <summary>
///
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public string SendMail(HttpContext context)
{
try
{
if (!string.IsNullOrEmpty(CookiesHelper.getCookie("send_mail_limit")))
{
return "-5";//
}
string email = context.Request["email"];
if (string.IsNullOrEmpty(email) || !CommonHelper.IsValidEmail(email))
{
return "-1";//
}
//
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";//
}
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";// , !
}
return "1";//
}
catch (Exception)
{
return "-4";//
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.