var FootS = document.getElementsByName("foot"); //这样当只有一个时也不出错了

解决方案 »

  1.   

    为什么为用个就行啊,请教getElementsByName和我写的什么区别啊?
      

  2.   

    当a为1时,FootS不是数组,所以用FootS.length就会出错.
    function checkForm() {
        var FootS = document.getElementsByName("foot"); 
        if(typeof Foots!=undefined){
    ..........     }
    }
      

  3.   

    无论有没有,有几个都行的函数<script language=JavaScript>
    function checkForm() {
        var FootS = document.memberform.elements['foot'];
    if (typeof(FootS) == 'undefined')
        alert("No Text Named By Foot");
    else if (!FootS.length)
    alert("Only One Text Named By Foot");
    else
    alert(FootS.length + " Texts Named By Foot");}
    </script>