6.0會出現死循環,下面的可以解決<html>
<body bgcolor="#eeeeee">
<form name="form1" method="post" action="">
  <input type="text" name="test1" onblur="if(this.value==''){alert('不能為空!');return false;this.focus();}">
  <input type="text" name="test2" onblur="if(this.value==''){alert('不能為空!');return false;this.focus();}">
</body>
</html>

解决方案 »

  1.   

    <html>
    <body bgcolor="#eeeeee">
    <form name="form1" method="post" action="">
      <input type="text" name="test1" onblur="if(this.value==''){alert('不能為空!');this.value=' ';this.focus();}">
    </body>
    </html>也行,建議有兩個input再最后一個才作判斷
      

  2.   

    試試下面的代碼:
    <body bgcolor="#eeeeee">
    <form name="form1" method="post" action="">
      <input type="text" name="test1">
      <input type="text" name="test2" onblur="if(test1.value=='' || this.value==''){alert('不能為空!');test1.value=' ';this.value=' ';test1.focus();test1.select();}">
    </body>
      

  3.   

    <html>
    <body bgcolor="#eeeeee">
    <form name="form1" method="post" action="">
      <input type="text" name="test1" onblur="if(this.value==''){alert('不能為空!');return false;this.focus();}">
      <input type="text" name="test2" onblur="if(this.value==''){alert('不能為空!');return false;this.focus();}">
    </body>
    </html>
      

  4.   

    <html>
    <script>var f=null</script>
    <body bgcolor="#eeeeee">
    <form name="form1" method="post" action="">
      <input type="text" name="test1" onfocus="if(f==this)f=null" onblur="if(f!=null)return;if(value==''){alert('Empty?');f=this;f.focus();}">
      <input type="text" name="test2" onfocus="if(f==this)f=null" onblur="if(f!=null)return;if(value==''){alert('Empty?');f=this;f.focus();}">
    </form>
    </body>
    </html>