登陆验证(ajax)
来源:互联网 发布:海南省最新网络诈骗案 编辑:程序博客网 时间:2024/05/17 03:55
1. login.ftl
<form id="userLogonForm" method="post" name="Logon" action="loginSubmit.jhtml"> <ul> <li> <label>個人郵箱</label> <input type="text" id="loginEmail" name="loginEmail"/> </li> <li> <label> 密码 </label> <input type="password" id="loginPassword" name="loginPassword"/> </li> </ul> <div class="actions"> <button id="loginBtn" type="button" value="登陆"> <span>登陆</span> </button> </div></form>
2.js
$loginBtn.click(function() { if (loginValidate()) { userLogin($loginPassword, $userLogonForm,$loginEmail, $itxLoading, request); }});
/** * 登录校验 */function loginValidate() { var flag = true; var $loginEmail = $("#loginEmail"); var $loginPassword = $("#loginPassword"); var regular = /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/; var illegalMsg = message('shop.validate.emailIllegal'); if (!$loginEmail.val()) { $.message("warn", message('shop.login.username.notEmpty')); $loginEmail.focus(); flag = false; } else if (!regular.test($loginEmail.val())) { $.message("warn", illegalMsg); $loginEmail.focus(); flag = false; } else if (!$loginPassword.val()) { $.message("warn", message('shop.login.password.notEmpty')); $loginPassword.focus(); flag = false; } return flag;}
/** * 用户登录 * * @param $loginPassword * @param $userLogonForm * @param $loginEmail */function userLogin($loginPassword, $userLogonForm, $loginEmail, $itxLoading,request) { $.ajax({ url : moshop.base + "/common/public_key.jhtml", type : "GET", dataType : "json", cache : false, success : function(data) { var rsaKey = new RSAKey(); rsaKey.setPublic(b64tohex(data.modulus), b64tohex(data.exponent)); var enPassword = hex2b64(rsaKey.encrypt($loginPassword.val())); $.ajax({ url : $userLogonForm.attr("action"), type : "POST", data : { username : $loginEmail.val(), enPassword : enPassword }, dataType : "json", cache : false, beforeSend : function() { $itxLoading.show(); }, success : function(message) { if (message.type == "success") { headerMenuControl(); closeDiv(); if (getCookie('fromCart')) { var $accountingType = $('input[name="accountingType"]:checked').val(); window.location.href = '/info.jhtml?accountingType=' + $accountingType; } else { if (request['redirectUrl']) { document.location.href = request['redirectUrl']; } else { document.location.href = moshop.base + '/common/default.jhtml'; } } } else { $.message('warn', message.content); return; } } }); } });}
注意对于:
var $accountingType = $('input[name="accountingType"]:checked').val();
有:
<input type="radio" class="in" name="accountingType" value="RMB" checked="checked"> <input type="radio" class="in" name="accountingType" value="DOLLARS">
注意:对于headerMenuControl();
/** * header menu Control */function headerMenuControl() { var $profile_name = $("#profile_name"); var name = getCookie("name"); $profile_name.text(name); $("#register").css({ 'display' : 'none' }); $("#showlogin").css({ 'display' : 'none' }); $("#logout").css({ 'display' : 'block' }); $("#usercenter").css({ 'display' : 'block' });}
对于:closeDiv();//关闭所有弹出层
function closeDiv() { hiddenMask(); $("#loginPapal").fadeOut('normal'); $("#registerUserPanel").fadeOut('normal'); $("#changeCurrency").fadeOut('normal');}/** * 单击事件,Mask罩盖层被销毁 */function hiddenMask() { var $itxOverlay_header = $("#itxOverlay-header"); $itxOverlay_header.fadeTo('slow', 0, function() { $itxOverlay_header.hide(); });};
0 0
- 登陆验证(ajax)
- Ajax验证用户登陆
- ajax登陆验证
- Ajax验证登陆
- 登陆验证ajax
- Django Ajax 登陆 验证
- Ajax简单客户登陆验证
- Ajax简单客户登陆验证
- Ajax简单客户登陆验证
- Ajax简单客户登陆验证
- 简单的ajax登陆验证
- 使用ajax进行登陆验证
- jsp ajax未刷新文本框信息验证 (登陆)
- Hibernate+Struts2+Ajax实现用户登陆验证
- ajax验证用户登陆及记住密码
- ajax验证用户登陆及记住密码
- ajax+jsp+servlet+mysql实现登陆验证
- Ajax如何实现注册登陆验证
- htmlr认识标签
- 递归和迭代的区别
- POJ 1118 && HDU 1432 Lining Up(计算几何)
- Android编译、打包的步骤
- 重要的事情看三遍!!!!!(持续更新中
- 登陆验证(ajax)
- 子类与父类中同名的变量是private,而父类中是public
- LeetCode:Valid Parentheses算法详解
- c语言-数组
- 辜舱祭铀只岳按酌咽
- 安装bcrypt报错node-gyp rebuild解决方法
- AFNetwork 2.5 修正版
- POJ 1816 Wild Words 字典树+DFS
- C#Dev DateEdit控件判定日期取值区间