• js 验证用户名和密码是否为空


        <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
          
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
          
        <html>  
          
          <head>  
          
            <title>My JSP 'userValidate.jsp' starting page</title>  
              
             <script type="text/javascript">  
                function checkUserName(obj){  
                    var username = obj;  
                    var checkUserNameResult = document.getElementById("checkUserNameResult");    
                    if(username.trim().length==0){  
                          checkUserNameResult.innerHTML = "用户名不能为空";    
                          obj.focus();  
                    }else{  
                         checkUserNameResult.innerHTML = "";    
                    }  
                }  
            </script>  
          
            <script type="text/javascript">  
                function checkPassword(obj){  
                    var password = obj;  
                    var checkPasswordResult = document.getElementById("checkPasswordResult");   
                    if(password.trim().length==0){  
                        checkPasswordResult.innerHTML = "密码不能为空";    
                        obj.focus();  
                    }else{  
                         checkPasswordResult.innerHTML = "";    
                    }  
                }  
          
            </script>  
          
          </head>  
          
          <body>  
          
            
          
          <table>  
              <tr>  
                <td>用户名:</td>  
                <td><input type="text" name="username"  onblur="checkUserName(this.value);" /></td>  
                <td><span id="checkUserNameResult" style="color: red "></span>  </td>  
            </tr>  
          
            <tr>  
          
            <td>密  码:</td>  
            <td><input type="password" name="password" onblur="checkPassword(this.value);"/>  
            <td><span id="checkPasswordResult" style="color: red "></span></td>  
           
            </tr>  
          
            <tr><td><input type="submit" value="提交" ></td></tr>  
          
            </table>  
          
          
          </body>  
          
        </html> 

  • 相关阅读:
    MyBatis动态SQL语句
    MyBatis分页
    理解 Linux 的处理器负载均值
    Linux命令之du
    Linux命令之df
    Linux命令之lsof
    maven打包加时间戳
    多线程学习-ListenableFuture使用介绍以及示例
    Host is not allowed to connect to this MySQL server解决方法
    Dapper,大规模分布式系统的跟踪系统
  • 原文地址:https://www.cnblogs.com/FLWL/p/6049286.html
Copyright © 2020-2023  润新知