<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>登入</title>
        <style>
            table{ border-collapse: collapse;}
            table th td { border:  1px solid black;}           
        </style>
    <script type="text/javascript">
        function checkform(){
            if(document.form.user.value==""){
                alert("用户名不能空!");
                document.form.user.focus();
            }else if(document.form.password.value==""){
                alert("密码不能空!");
            }else{
                document.form.submit();
            }
        }
    </script>
    </head>
    <body>
        <form name="form" action="checklogin.jsp">
            <table align="center">
                <caption>登入</caption>
                <tbody>
                    <tr>
                        <td>用户名:</td>
                        <td><input type="text" name="user" value="" /></td>
                    </tr>
                    <tr>
                        <td>密码:</td>
                        <td><input type="password" name="password" value=""/></td>
                    </tr>
                    <tr>
                        <td><input type="button" value="进入" name="button" onClick="checkform()"/></td>
                        <td><a href="register.jsp">注册</a></td>
                    </tr>
                </tbody>
            </table>        </form>
    </body>
</html>
这段代码在firefox中能顺利调用javascript函数checkform()判断文本框不能为空,但在chrome中不能执行。
求高人指点,该怎么修改解决问题。。