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>
  • 相关阅读:
    元素和容器, Model and View
    KeyboardHook in C#
    项目步骤
    对编程的思考
    Web开发中使用数据库的3种方式
    动态得到属性的名字
    WPF Databinding examples
    【SPOJ】220 Relevant Phrases of Annihilation
    【FOJ】2075 Substring
    【UVa】760 DNA Sequencing
  • 原文地址:https://www.cnblogs.com/dty602511/p/14173718.html
Copyright © 2011-2022 走看看