<script>
function check(obj)
{
if(obj!=null)
alert("yes");
else
alert("no");
}
</script>
<input type=text name=mytext>
<input type=button name=mybutton onclick=check(document.all.mytext)>
<input type=button name=mybutton2 onclick=check(document.all.text)>
function check(obj)
{
if(obj!=null)
alert("yes");
else
alert("no");
}
</script>
<input type=text name=mytext>
<input type=button name=mybutton onclick=check(document.all.mytext)>
<input type=button name=mybutton2 onclick=check(document.all.text)>
obj=document.all.tags("INPUT");
alert(obj.length);
</script>
这样判断:if(input的id) alert("input存在");
5.0 5.5都可用
alert(document.getElementsByName("mytext").length)