日期:2014-05-16  浏览次数:20338 次

问个超弱智的问题
<script   language= "javascript ">
function   yuan()
{
if(document.all.abc.getElementByName( "abc1 ").innerText== " "   &&   document.all.abc.getElementByName( "abc2 ").innerText   &&  

document.all.abc.getElementByName( "abc3 ").innerText== " ")
alert( "请输入密码 ");
document.abc.submit();
}
</script>


<body   onLoad= "yuan(); ">
<form   name= "abc ">
<input   type= "text "   name= "abc1 ">
<input   type= "text "   name= "abc2 ">
<input   type= "text "   name= "abc3 ">
<a   href= "# "   onclick= "yuan(); "> 提交 </a>
</form>
</body>

运行不起,

------解决方案--------------------
这样改
<script language= "javascript ">
function yuan()
{
if(document.getElementsByName( "abc1 ")[0].innerText== " " && document.getElementsByName( "abc2 ")[0].innerText && document.getElementsByName( "abc3 ")[0].innerText== " ")
alert( "请输入密码 ");
document.abc.submit();
}
</script>

<body onLoad= " ">
<form name= "abc ">
<input type= "text " name= "abc1 ">
<input type= "text " name= "abc2 ">
<input type= "text " name= "abc3 ">
<a href= "# " onclick= "yuan(); "> 提交 </a>
</form>
</body>