读书人

问个超弱智的有关问题

发布时间: 2012-03-03 15:33:04 作者: rapoo

问个超弱智的问题
<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>

读书人网 >JavaScript

热点推荐