zoukankan      html  css  js  c++  java
  • 11.27

     今天学了

     创建登录界面
    登录界面用于输入用户的用户名和口令,用到的知识点与前面介绍的注册功能用到的
    知识点完全相同,下面只给出参考代码。
    <%@ page contentType="textml;charset=gb2312"%>
    <script language="JavaScript">
     function isValidate(form)
     {
     // 得到用户输入的信息
     userid = form.userid.value;
     userpass = form.userpass.value;
     // 判断用户名长度
     if(!minLength(userid,6))
     {
     alert("用户名长度小于 6 位!");
     form.userid.focus();
     return false;
     }
     if(!maxLength(userid,8))
     {
     alert("用户名长度大于 8 位!");
     form.userid.focus();
     return false;
     }
     // 判断口令长度
     if(!minLength(userpass,6))
     {
     alert("口令长度小于 6 位!");
     form.userpass.focus();
     return false;
     }
     if(!maxLength(userpass,8))
     {
     alert("口令长度大于 8 位!"); 

    form.userpass.focus();
    return false;
    }
    // 判断用户名和口令是否相同
    if(userid==userpass)
    {
    alert("用户名和口令不能相同!");
    form.userpass.focus();
    return false;
    }
    return true;
    }
    // 验证是否满足最小长度
    function minLength(str,length)
    {
    if(str.length>=length)
    return true;
    else
    return false;
    }
    // 判断是否满足最大长度
    function maxLength(str,length)
    {
    if(str.length<=length)
    return true;
    else
    return false;
    }
    </script>
    <html>
    <head>
    <title>用户登录</title>
    </head>
    <body>
    <h2>用户登录</h2>
    <form name="form1" action="login_process.jsp" method="post"
    onsubmit="return isValidate(form1)">

     用户名:<input type="text" name="userid"> <br>
     口令:<input type="password" name="userpass"><br>
     <input type="reset" value="重置">
     <input type="submit" value="提交"><br>
     </form>
     </body>
    <html>
  • 相关阅读:
    hibernate中的缓存和快照
    hibernate中的主键生成策略
    static静态代码块的使用(单例)
    spring aop简单实现
    spring 中常用注解
    spring 配置文件中<property> 的作用
    spring配置文件中引入其他配置文件的方法
    3-29 from xx import xx
    3-28 遇到的问题及解决方法
    3-27 思考以及self本质
  • 原文地址:https://www.cnblogs.com/dty602511/p/14173718.html
Copyright © 2011-2022 走看看