for(i = 0;i<document.getElementsTagName("INPUT").length;i++)
{
 alert(ocument.getElementsTagName("INPUT")[i].value)
}

解决方案 »

  1.   


    for(i = 0;i <document.getElementsByTagName("INPUT").length;i++)
    {
      alert(document.getElementsByTagName("INPUT")[i].value);
    }
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    </head>
    <script>
    var check = function()
    {
    len = document.getElementsByTagName("input").length;
    for(i=0;i<len-1;i++)
    {
    if(document.getElementsByTagName("input")[i].value == "")
    {
    alert("第" + (i+1) +"个文本框为空");
    }
    }
    }
    window.onload = function()
    {
    if(document.all)
    {
    document.body.lastChild.previousSibling.attachEvent("onclick",check);
    }
    else
    {
    document.getElementsByTagName("body")[0].addEventListener("click",check);
    }
    }
    </script>
    <body>
    <input type="text" value="1"><input type="text" ><input type="text" ><input type="text" value="2" ><input type="text" ><input type="button" value="测试">
    </body>
    </html>
      

  3.   

    改一下兼容FF的.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    </head>
    <script>
    var check = function()
    {
    len = document.getElementsByTagName("input").length;
    for(i=0;i<len-1;i++)
    {
    if(document.getElementsByTagName("input")[i].value == "")
    {
    alert("第" + (i+1) +"个文本框为空");
    }
    }
    }
    window.onload = function()
    {
    if(document.all)//IE
    {
    document.body.lastChild.previousSibling.attachEvent("onclick",check);
    }
    else//FF
    {
    document.body.lastChild.previousSibling.addEventListener("click",check,false);
    }
    }
    </script>
    <body>
    <input type="text" value="1"><input type="text" ><input type="text" ><input type="text" value="2" ><input type="text" ><input type="button" value="测试">
    </body>
    </html>
      

  4.   

    for(i = 0;i <document.getElementsByTagType("INPUT").length;i++)
    {
      alert(document.getElementsByTagName("INPUT")[i].value);
    }