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>
<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>
解决方案 »
- jquery中,这个this指的是谁?
- 如何使用正则表达式过滤掉标签中的Style、width、height属性
- 在百度贴吧tieba.baidu.com上添加一个IFRAME,却提示IFRAME拒绝访问
- 各位大侠啊, 我想遍历DOM树, 不知道, 应该在哪个事件中执行呀?
- 一个form中有两个type="image"的input可以吗?如果可以,如何使按第一个input提交到A.jsp,按第二个input提交到b.jsp,下面实现有问题吗?
- 表单提交问题!
- 如何获得滚动条发生了滚动的事件?
- 由树型菜单改装的下拉菜单_跟贴就给分,欢迎发表见解
- 有许多问题要问!!帮我
- 初学者的问题,请高手赐教!
- 为什么这段代码在普通页面可以用,而在表单里就不能用呢?
- 如何用javascript将下列一段xml代码显示为树状?
<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再最后一個才作判斷
<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>
<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>
<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>