打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
我写的一个登录框
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp" %>
<%
String url=request.getParameter("url");
request.setAttribute("nsLogin",request.getParameter("nsLogin"));
%>


<style type="text/css">
.bodybg { position:fixed; top:0; left:0; z-index:20; width:100%; height:100%; background:#000; filter:alpha(opacity=40); opacity:0.4; }
.loginBox { position:fixed; width:760px; height:350px; padding:1px; background:#fff; border-radius:10px; left:50%; top:50%; margin-left:-380px; margin-top:-184px; font-size:14px; z-index:30;}
.logincont { padding-left:415px; padding-top:30px; background:url(${portalLoginUrl}/sportal/skins/loginImages/loginbg.jpg) no-repeat; height:285px;}
.loginBox td { padding:10px 0;}
.loginBox .action { padding:7px 0;}
.loginBox h4 { height:33px; line-height:33px; background:#c0e5ff; padding-left:17px; font-size:15px; color:#2779b3; border-top-left-radius:10px;border-top-right-radius:10px; font-family:"Microsoft YaHei";}
.all-input { color:#a5a5a5; height:34px; line-height:34px; background:url(${portalLoginUrl}/sportal/skins/loginImages/mayicon.gif) repeat-x 0 -128px; border:1px solid #cacaca; padding:0 5px 0 10px; width:275px;}
.all-input2 { width:155px;}
.sub { width:294px; height:36px; background:url(${portalLoginUrl}/sportal/skins/loginImages/btn.jpg) no-repeat; border:0 none; cursor:pointer;}
.loginBox .forget { width:290px; text-align:right;}
.loginBox .closed { position:absolute; width:20px; height:20px; background:url(${portalLoginUrl}/sportal/skins/loginImages/closed.jpg) no-repeat; cursor:pointer; right:10px; top:10px;}
</style>
<script src="${root}/common/js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
var i=0;
var j=0;
var isLogining = false;
var isAnzhuang=false;
function chkSubmit(frm,ismanager) {
if(isLogining){
return false;
}
if(frm.loginName.value.length!=0&&frm.password.value.length!=0&&frm.rand.value.length!=0){
i=1;
j=1;
}
if (frm.loginName.value=="手机号/邮箱") {
    $("#errorType").html("用户名不允许为空!");
   
    frm.loginName.focus();
    return false;
   }
else{
if(i==0){
if(frm.password.value=="登录密码"){
frm.password.focus();
$("#errorType").html("密码不允许为空!");
}
i++;
return false;
}
}
   if (frm.password.value=="登录密码") {
    $("#errorType").html("密码不允许为空!");
    frm.password.focus();
    return false;
   }
   else{
       if(frm.rand.value=="验证码"){
        $("#errorType").html("请输入图形验证码!");
    frm.rand.focus();
       }
    if(j==0){
j++;
return false;
}
   }
   if (frm.rand.value=="验证码") {
$("#errorType").html("请输入图形验证码!");
frm.rand.focus();
return false;
}
   saveUser();
   if (!isAnzhuang) {
    var params=$("#loginFrm").serialize();
    $.ajax({
  type: "POST",
  url: '${root}/login/Login/validateUser.jspx?date='+new Date().getTime(),
  data:params,
  success: function(msg){
  if (msg=="success"){
   $(".x_zhezhaoceng").show(); 
  $(".x_tanchu").show();
  $("#errorType").html(" ");
  return false;
  }else if (msg=="ImageChkFailed"){
 $("#errorType").html("验证码错误!");
 frm.rand.focus();
 return false;
  }else if (msg=="UserInactive"){
 $("#errorType").html("用户名或密码错误!");
  frm.loginName.focus();
 return false;
  }else if (msg=="UserInactiveStatus"){
 $("#errorType").html("账号已被锁定!");
 frm.loginName.focus();
 return false;  
  }else {
  return false;
  }
  }
}); 
   
   } else {
   
    //$('#loginBtn').html('登录中...');
    //document.getElementById('loginBtn').disabled="disabled";
    //document.getElementById('loginBtn').style.cursor="default";
isLogining=true;
var params=$("#loginFrm").serialize();
    $.ajax({
  type: "POST",
  url: '${root}/login/Login/validateUser.jspx?date='+new Date().getTime(),
  data:params,
  success: function(msg){
 
  if (msg=="success"){
 document.frm.submit();
  }else if (msg=="ImageChkFailed"){
 $("#errorType").html("验证码错误!");
 frm.rand.focus();
$('#loginBtn').html('登录');
      //document.getElementById('loginBtn').disabled="";
      //document.getElementById('loginBtn').style.cursor="print";
      isLogining=false;
 return false;
  }else if (msg=="UserInactive"){
 $("#errorType").html("用户名或密码错误!");
 frm.loginName.focus();
$('#loginBtn').html('登录');
      document.getElementById('loginBtn').disabled="";
      document.getElementById('loginBtn').style.cursor="print";
      isLogining=false;
return false;
  }else if (msg=="UserInactiveStatus"){
 $("#errorType").html("账号已被锁定!");
 frm.loginName.focus();
$('#loginBtn').html('登录');
      //document.getElementById('loginBtn').disabled="";
      //document.getElementById('loginBtn').style.cursor="print";
      isLogining=false;
return false;  
  }
  }
}); 
   }
}
//保存用户信息
function saveUserInfo() {
if(document.getElementById("nolonger").checked){
       $.cookie("nolonger", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
       isAnzhuang=true;
   }
   else {
       $.cookie("nolonger", "false", { expires: -1 });
       isAnzhuang=false;
   }
document.getElementById('x_btn').disabled="disabled";
$('#loginBtn').html('登录中...');
document.getElementById('loginBtn').disabled="disabled";
document.getElementById('loginBtn').style.cursor="default";
isLogining=true;
document.frm.submit();
}
function enter(frm,evt) {
var k=window.event?evt.keyCode:evt.which;
if (k==13) {
chkSubmit(frm); 
}
}
function enter(evt) {
var k=window.event?evt.keyCode:evt.which;
if (k==13) {
luceneSearch();
}
function change_authimage()
{
document.getElementById('authimage').src="${root}/common/authimage/authimage.gif?r="+Math.random();
}
function selectName(){
document.getElementById("loginName").focus();
}
//初始化页面时验证是否记住了不在提醒
function readercookie(){
   if ($.cookie("nolonger") == "true" || '${nsLogin}' == 'true') {
    isAnzhuang=true;
   }else {
    isAnzhuang=false;
   }
   if ($.cookie("rememberLm") == "true") {
       $("#rememberLm").attr("checked", true);
       $("#loginName").val($.cookie("loginName"));
   }
   if ($.cookie("rememberPwd") == "true") {
       $("#rememberPwd").attr("checked", true);
       $("#password").val($.cookie("password"));
   }
    }
$(document).ready(function(){
readercookie();
});
//保存用户信息
function saveUser() {
if(document.getElementById("rememberLm").checked){
       var userName = $("#loginName").val();
       $.cookie("rememberLm", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
       $.cookie("loginName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie
   } else {
       $.cookie("rememberLm", "false", { expires: -1 });
       $.cookie("loginName", '', { expires: -1 });
   }
if(document.getElementById("rememberPwd").checked){
var passWord = $("#password").val();
       $.cookie("rememberPwd", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
       $.cookie("password", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie
       
   } else {
       $.cookie("rememberPwd", "false", { expires: -1 });
       $.cookie("password", '', { expires: -1 });
   }
}
function checkBoxClick(checkBoxId){
var check=document.getElementById(checkBoxId);
if (check.checked){
check.checked=false;
}else
{
check.checked=true;
}
}
</script>
<div class="bodybg"></div>
<s:form action="Login/login.jspx" method="post" namespace="/login" name="frm" id="loginFrm" target="loginIframe" >
<input type="hidden" name="url" value="<%=url%>"/>
<input type="hidden" name="imagechk" value="true"/>
<input type="hidden" name="nsLogin" value="true"/>
<div class="loginBox">
<h4>35空间用户登录</h4>
    <span class="closed"></span>
    <div class="logincont">
    <table>
    <tbody>
        <tr>
            <td colspan="2"><input type="text" onkeyup="enter(this.form,event)" tabindex="1" name="loginName" id="loginName" class="all-input" value="手机号/邮箱" onfocus="if(this.value==this.defaultValue){this.value='';}; this.style.color='black';" onblur="if(this.value==''){this.value=this.defaultValue;}; this.style.color='#A4A4A4'" /></td>
               
            </tr>
            <tr>
            <td colspan="2"><input type="password" class="all-input" value="登录密码" name="password" id="password" onkeypress="enter(this.form,event)" tabindex="2"   onfocus="if(this.value==this.defaultValue){this.value='';}; this.style.color='black';" onblur="if(this.value==''){this.value=this.defaultValue;}; this.style.color='#A4A4A4'" /></td>
            </tr>
            <tr>
            <td  style="padding-buttom:5px;"><input type="text" name="rand" onkeypress="enter(this.form,event)"  tabindex="3" class="all-input all-input2" value="验证码"  onfocus="if(this.value==this.defaultValue){this.value='';}; this.style.color='black';" onblur="if(this.value==''){this.value=this.defaultValue;}; this.style.color='#A4A4A4'" /></td>
                <td ><img src="${root}/common/authimage/authimage.gif" id="authimage" name="authimage" alt="" style="float:left;margin-top:8px; margin-left:8px;" /> <a href="#" onclick="change_authimage();" style="float:left; margin-top:15px;">  换一张</a></td>
            </tr>
            <tr>
            <td  style="padding-top:2px;padding-buttom:5px;" class="action"><span style="margin-top:0px;float:left;"> <input  type="checkbox"  id="rememberLm"  value="" /></span><div style="float:left;margin-top: -4px;*margin-top:0px;margin-left:10px;cursor:pointer;" onclick="checkBoxClick('rememberLm')">记住用户名</div></td><td  style="padding-top:2px;padding-buttom:5px;" class="action"> <span style="float:left;"><input type="checkbox" id="rememberPwd" value=""  /></span><div style="float:left;margin-top: -4px;*margin-top:0px;margin-left:10px;cursor:pointer;" onclick="checkBoxClick('rememberPwd')">记住密码</div></td>
            </tr>
            
            <tr>
            <td colspan="2" class="action"><input type="button" onclick="chkSubmit(document.forms[0],'2')" id="loginBtn"  class="sub" value="" /></td>
            </tr>
            <tr>
               <td style="padding-top:2px;padding-buttom:2px;color:red;" id="errorType" ></td> <td style="padding-top:2px;padding-buttom:2px;"><p  class="forget" style="width:120px;"><a  style="margin-right:20px;" href="#" onclick="window.open('${root}/register.jsp')">注册</a><a href="#"  onclick="window.open('${root}/find_pwd.jsp')">忘记密码</a></p></td>
            </tr>
        </tbody>
    </table>
    </div>
</div>
</s:form>
 <iframe src="" id="loginIframe" name="loginIframe"  frameborder="0" style="height: 0px;width: 0px;display:none;"></iframe>
<script type="text/javascript">
$(".loginBox .closed").click(function(){
$(".loginBox, .bodybg").hide();
})
</script>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
jQuery加PHP实现图片上传并提交
AJAX基础2-JSON-JSON分页-FormData-上传-进度条-聊天-天气预报
JQUERY 多行动画改变高度
使用iframe实现,点击JSP页面中的验证码刷新
php 验证码生成
JavaScript动画实例:运动的字母特效
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服