zoukankan      html  css  js  c++  java
  • 判断是否为空

    <!DOCTYPE html>
    <html>
     <head>
      <meta charset="UTF-8">
      <title></title>
      <script type="text/javascript">
      
       function show(id,info){
        var el = document.getElementById("user").value;
        var a = document.getElementById(id+"Name");
        if(el==""){
         a.style.display="inline-block";
         a.innerHTML=info;
        }else{
         a.style.display="none";
        }
       }
       onblur="check('user','用户名不能为空')"
       function check(id,info){
        var el = document.getElementById("user").value;
        var a = document.getElementById(id+"Name");
        if(el==""){
         a.style.display="inline-block"; 
         a.innerHTML=info;
        }else{
         a.style.display="none";
        }
       }
       
      </script>
     </head>
     <body>
      <table  cellspacing="0" cellpadding="0">
       <tr>
        <td>用户名</td>
        <td>
         <input type="text" id="user" onfocus="show('user','用户名必填')" onblur="check('user','用户名不能为空')"/><span id="userName" ></span>
        </td>
       </tr>
       <tr>
        <td>密码</td>
        <td>
         <input type="password" id="password" onfocus="show('password','密码必填')" onblur="check('password','密码不能为空')"/><span id="passwordName" ></span>
        </td>
       </tr>
       <tr>
        <td>确认密码</td>
        <td>
         <input type="password" id="passwordAgain" onfocus="show('passwordAgain','密码必填')" onblur="check('passwordAgain','密码不能为空')"/><span id="passwordAgainName" ></span>
        </td>
       </tr>
      </table>
     </body>
    </html>

  • 相关阅读:
    C++实例 分解质因数
    C++语言 堆排序
    下载吧压缩工具(360超级注释压缩)
    unresolved external symbol __endthreadex错误解决
    C语言 常用函数A
    C++实例 获取进程所在文件夹
    IIS 服务或万维网发布服务,或者依赖这 服务可能在启动期间发生错误或者已禁用
    字體的css
    ubuntu下mono初体验<一>
    NOSQL之mongodb简介及安装 for linux(centOS)<二>
  • 原文地址:https://www.cnblogs.com/zdy-123/p/10455584.html
Copyright © 2011-2022 走看看