为什么我输入的密码不同,但是dir内容无法显示出来??请高手们指点!!!
<html>
<head>
<title>
third
</title>
<script language="JavaScript" type="">
function checkpwd()
{
  var objDiv = document.getElementById("tipDiv");
  var pwd = document.myform.password.value;
  var conpwd = document.myform.confirmPwd.value;
  if(pwd==conpwd)
  {
    objDiv.style.display="none";
  }
  else
  {
    objDiv.style.diaplay="block";
  }
}
</script>
</head>
<body bgcolor="#ffffff">
<h1 align="center">
style.diaplay测试
</h1>
<form action="" name="myform">
  <table align="center">
    <tr>
      <td>密码:</td>
      <td><input type="text" name="password" id="password"/></td>
    </tr>
    <tr>
      <td>确认:</td>
      <td><input type="text" name="confirmPwd" id="confirmPwd"/></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="button" name="button1" value="确定" id="button1" onclick="checkpwd()"/></td>
    </tr>
    <tr>
      <td colspan="2"><dir id="tipDiv" style="display:none;">密码不相同!</dir></td>
    </tr>
  </table>
</form>
</body>
</html>

解决方案 »

  1.   

    <dir id="tipDiv" style="display:none;">密码不相同!</dir>------->>>
    <div id="tipDiv" style="display:none;">密码不相同!</div>
      

  2.   

    <script   language= "JavaScript "   type= " "> ??
    type 没指定!还有就是楼上说的拼写错误。lz再检查一下吧,没准还有地方漏了,建议用VS2005编辑,它会提示你哪些代码不合标准(虽然不符合标准有时候也可以正常工作)。
      

  3.   

    1.type= " "   type= "text/JavaScript"
    language= "JavaScript "   language= "JavaScript"
    注意"JavaScript"后面没有空格
    其他<input   type= "text "   name= "password "   id= "password "/>等等也是一样,你的这些对象的ID都带有一个空格,所以document.myform.password就没法找到那个元素
    请注意你那些乱七八糟的空格,<form   action= " "   name= "myform ">, name= "myform "中带有一个空格,所以 document.myform就找不到它,用document.getElementById( "password ")【有空格】才能找到它
    2.objDiv.style.diaplay= "block ";你自己检查这个错在哪儿<html> 
    <head> 
    <title> 
    third 
    </title> 
    <script   language= "JavaScript"   type= "text/JavaScript"> 
    function   checkpwd() 

        var   objDiv   =   document.getElementById( "tipDiv "); 
        var   pwd   =   document.getElementById( "password ").value; 
        var   conpwd   =   document.getElementById( "confirmPwd ").value; 
        if(pwd==conpwd) 
        { 
            objDiv.style.display= "none"; 
        } 
        else 
        { 
            objDiv.style.display= "block"; 
        } 

    </script> 
    </head> 
    <body   bgcolor= "#ffffff "> 
    <h1   align= "center "> 
    style.diaplay测试 
    </h1> 
    <form   action= " "   name= "myform "> 
        <table   align= "center "> 
            <tr> 
                <td> 密码: </td> 
                <td> <input   type= "text "   name= "password "   id= "password "/> </td> 
            </tr> 
            <tr> 
                <td> 确认: </td> 
                <td> <input   type= "text "   name= "confirmPwd "   id= "confirmPwd "/> </td> 
            </tr> 
            <tr> 
                <td   colspan= "2 "   align= "center ">
                 <input   type= "button"   name= "button1 "   value= "确定 "   id= "button1 "   onclick= "checkpwd() "/> </td> 
            </tr> 
            <tr> 
                <td   colspan= "2 "> <dir   id= "tipDiv "   style= "display:none; "> 密码不相同! </dir> </td> 
            </tr> 
        </table> 
    </form> 
    </body> 
    </html>