解决方案 »

  1.   


    <%@ page contentType="text/html;charset=utf-8" language="java"%>
    <%
    String Username = request.getParameter("uid");
    String Password = request.getParameter("password");
    String input = request.getParameter("rand");
    if (Username != null && Password != null) {
    session.setAttribute("input", input);
    if (input.equals(session.getAttribute("random"))) {
    response.sendRedirect("loginAction.jsp");
    } else {
    response.sendRedirect("error.jsp");
    }
    }
    %><script type="text/javascript">
    function check() {
    if (loginForm.Username.value == "") {
    alert("请输入用户名!!!");
    loginForm.Username.focus();
    retValue = false;

    if (loginForm.Password.value == "") {
    alert("请输入密码!!!");
    loginForm.Password.focus();
    return false;
    }
    return true;
    }
    function doCheckAndSubmit() {
    if (check()){
    document.forms(0).submit();
    }
    }
    </script><html>
    <link href="../css/login.css" rel="stylesheet" type="text/css" />
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>用户登录</title>
    <meta http-equiv="expires" content="0">
    <style type="text/css">
    <!--
    .style1 {
    color: #0000CC;
    font-size: 16px;
    font-weight: bold;
    }
    -->
    </style>
    </head>
    <body>
    <form name="loginForm" method="post" action="loginAction.jsp">
    <table width="50%" border="1" align="center" cellpadding="0"
    cellspacing="0" bordercolor="#CCCCCC">
    <caption>
    <span class="style1"> 登 录 </span><br>
    </caption>
    <tr align="left">
    <th width="40%" height="35" align="center" scope="row">用户名:</th>
    <td width="60%"><input name="uid" type="text" id="uid"
    maxlength="20"></td>
    </tr>
    <tr align="left">
    <th height="35" align="center" scope="row">密&nbsp;&nbsp;码:</th>
    <td><input name="password" type="password" id="password"
    maxlength="30"></td>
    </tr>
    <tr align="left">
    <th width="40%" height="35" align="center" scope="row">认证码:</th>
    <td width="181" height=35><input type=text name=rand
    maxlength="30%" value="" size=6> &nbsp;&nbsp; <img border=1
    src="image.jsp"></td></tr>
    <tr align="center">
    <th height="35" colspan="3" scope="row"><input type="button" onclick="javascript:doCheckAndSubmit();"
    name="Submit" value="登录"> <INPUT type="reset" name="Reset"
    value="重置"> <input type="button" name="Submit2" value="注册"
    onclick="javascript:window.location='userRegister.jsp'"></th>
    </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    可以说清楚点吗,没怎么接触过web开发
      

  3.   

    <input type="submit"
    name="Submit" value="登录"  onclick=“check();”>
      

  4.   

    晕,你们说的方法都试了,还不执行check()方法。
      

  5.   

    首先,你的jsp部署到ap server了没?
    其次,换个名字check123啥的试试
      

  6.   

    <script type="text/javascript">
    function check() {
    if (loginForm.uid.value == "") {//这里应该是uid
    alert("请输入用户名!!!");
    loginForm.Username.focus();
    return false;
    }
    if (loginForm.Password.value == "") {
    alert("请输入密码!!!");
    loginForm.password.focus();//你的这里的P应该是小写的 。
    return false;
    }
    }
      

  7.   

    function check() {if (loginForm.uid.value == ""||loginForm.uid.value==null) {
    alert("请输入用户名");
    loginForm.uid.focus();
    return false;
    }if (loginForm.password.value == "") {
    alert("请输入密码!!!");
    loginForm.password.focus();
    return false;
    }}