<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)>

解决方案 »

  1.   

    <script>  
    obj=document.all.tags("INPUT");  
    alert(obj.length); 
    </script>
      

  2.   

    if(obj!=null) 这句在ie5.0中会出错。
    这样判断:if(input的id) alert("input存在");
    5.0 5.5都可用
      

  3.   

    try{document.all.该input.value}catch(e){alert('不存在')}
      

  4.   

    ???
    alert(document.getElementsByName("mytext").length)