密码不一致,为什么实现不了啊

              <tr>  <td class="n1">用户名:</td>   <td><input id="username" type="text" name="username" /></td> </tr>                          
              <tr>  <td class="n1">邮箱:   </td>   <td><input id="email" type="email" name="email" /></td> </tr>
              <tr>  <td class="n1">密码:   </td>   <td><input id="pass" type="password" name="pass"/></td></tr>
              <tr>  <td class="n1">确认密码:</td> <td><input id="pass1" type="password" name="pass1" /></td></tr>
              <tr>  <td class="n1">手机号码:</td> <td><input id="tele" type="text" name="telephone"></td></tr>
              <tr></tr>
              <tr><td><input  class="login" name="login" type="submit" value="注册" onclick="check()"/></td>
                  <td><input  id="a1" type="button" value="返回" onclick="back()"/></td>
                  </tr>
          </table>
        </form>//为什么没密码验证功能啊?



<script type="text/javascript" src="../pwcheck.js"></script>
function check(){
         var password = document.getElementsById("pass");
         var password1= document.getElementsById("pass1");
         var i=document.getElementByClassName("login");
         i[1].onclick=function(){
                if(password1.value != password.value){
                   alert("密码不一致,请重新输入密码");
                   i.type = "button";
                   password.value="";
                   password1.value="";                                          
                }else{
                i.type="submit";                    
                }                    
            };
         function back(){
             var oBtn = document.getElementById("a1");
             oBtn.onclick = function(){
                 window.location.reload();
             };
        }
    back(this);                                      
};
   

document.getElementById,不是document.getElementsById,多了个s
document.getElementBysClassName,不是document.getElementByClassName,少了个s

刚好反过来了。。-_-||。。
样式为login的元素只有一个,i[1]越界了,应该是i[0],
也没验证密码是否输入了内容,那么什么都不填写,直接提交if(password1.value != password.value)这句也没用了
back函数放到check内部,这样外部就无法访问了,点击返回按钮报错。

而且代码逻辑太乱了。。直接用check事件就行了,不用在check中再绑定click事件,dom是submit按钮,直接提交表单了,在绑定事件也没用了,。

好多问题。改下面的就好了

<form>
    <table border="1">
        <tr>  <td class="n1">用户名:</td>   <td><input id="username" type="text" name="username" /></td> </tr>
        <tr>  <td class="n1">邮箱:   </td>   <td><input id="email" type="email" name="email" /></td> </tr>
        <tr>  <td class="n1">密码:   </td>   <td><input id="pass" type="password" name="pass" /></td></tr>
        <tr>  <td class="n1">确认密码:</td> <td><input id="pass1" type="password" name="pass1" /></td></tr>
        <tr>  <td class="n1">手机号码:</td> <td><input id="tele" type="text" name="telephone"></td></tr>
        <tr></tr>
        <tr>
            <td><input class="login" name="login" type="submit" value="注册" onclick="return check()" /></td>
            <td><input id="a1" type="button" value="返回" onclick="back()" /></td>
        </tr>
    </table>
</form>
<script>
    function check() {
        var password = document.getElementById("pass");
        var password1 = document.getElementById("pass1");
        var i = document.getElementsByClassName("login");

        if (password.value == '') {
            alert('请输入密码!');
            password.focus();
            return false;///////阻止表单提交
        }
        if (password1.value != password.value) {
            alert("密码不一致,请重新输入密码");
            i.type = "button";
            password.value = "";
            password1.value = "";
            return false;///////阻止表单提交
        } 

    }
    function back() {
        window.location.reload();
    }

</script>


有帮助麻烦点下【采纳该答案】,谢谢~~有其他问题可以继续交流~

点击事件估计都没触发。方法内alert()测试一下。
i[1].onclick=function(){}
为什么用这种方式?直接给按钮绑定一个id属性不好吗?

用双等于号
password1.value !== password.value

你只是在注册按钮的点击事件check里又给注册按钮绑定了个点击事件,但是没触发啊,怎么会去判断不等呢。
把onclick里的东西拿出来放到check里就行了。
还有,不等于用!==