怎么用javascript判断文本框是否为空?

来源:互联网 发布:手机淘宝我是商家在哪 编辑:程序博客网 时间:2024/05/01 02:17
 <!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN"  
  "http://www.w3.org/TR/html4/loose.dtd">  
  <html>  
  <head>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">  
  <title>无标题文档</title>  
  </head>  
  <script   language="javascript">  
  <!--  
  function   isfull(){  
   
      if   (document.dd.username.value==""){  
      alert("用户名不能为空");  
      document.dd.username.focus();  
      return   false;  
    }  
    if   (document.dd.password.value==""){  
      alert("密码不能为空");  
      document.dd.password.focus();  
      return   false;  
  }  
  return   true;}  
  </script>  
  <body>  
  <form   name="dd"   method="post"   action=""   onSubmit="return   isfull();">  
      <input   type="text"   name="username">  
   
   
      <input   type="text"   name="password">  
      <input   type="submit"   name="Submit"   value="提交">  
  </form>  
  </body>  
  </html>
原创粉丝点击