Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么表格不提交 函数验证() { var pass1=document.form1.pw.value; var user=document.form1.name.value; if(user.length==0) { 警告(“用户名不应为Black”); document.form1.name.focus(); 返回false; } if(pass1.length==0) { 警报(“您必须输入密码”); document.form1.pw.focus(); 返回false; } 如果(pass1.length_Javascript_Php_Html - Fatal编程技术网

Javascript 为什么表格不提交 函数验证() { var pass1=document.form1.pw.value; var user=document.form1.name.value; if(user.length==0) { 警告(“用户名不应为Black”); document.form1.name.focus(); 返回false; } if(pass1.length==0) { 警报(“您必须输入密码”); document.form1.pw.focus(); 返回false; } 如果(pass1.length

Javascript 为什么表格不提交 函数验证() { var pass1=document.form1.pw.value; var user=document.form1.name.value; if(user.length==0) { 警告(“用户名不应为Black”); document.form1.name.focus(); 返回false; } if(pass1.length==0) { 警报(“您必须输入密码”); document.form1.pw.focus(); 返回false; } 如果(pass1.length,javascript,php,html,Javascript,Php,Html,,似乎存在歧义问题,因为您已将提交按钮命名为submit: 由于以下错误,表单未提交: 仔细检查代码后,您的表单html似乎有一个输入错误: <html> <head><br></head> <body> <meta charset="UTF-8"> <script type="text/javascript"> function validate()

,似乎存在歧义问题,因为您已将提交按钮命名为
submit


由于以下错误,表单未提交:

仔细检查代码后,您的表单html似乎有一个输入错误:

    <html>
    <head><br></head>
    <body>
    <meta charset="UTF-8">

    <script type="text/javascript">
    function validate()
    {

        var pass1=document.form1.pw.value;
        var user=document.form1.name.value;
                if(user.length==0)
                {
                         alert( "Username Should not be blanck");
                         document.form1.name.focus();
                         return false;
                }
            if (pass1.length == 0) 
            {
                alert("You must enter  password");
                document.form1.pw.focus();
                return false;
             }
              if(pass1.length<4)
              {  
                  alert("Password length should not be less than 4 characters");
                   document.form1.pw.focus();
                    return false;    
              } 
               //alert("submit");
           document.form1.submit();
                return true;          
    }
    </script>
      <form action="Authenticate1.php" method="post"  name="form1" id="form1" enctype="multipart/form-data"  ">
    <table width="40%"  border="1"> 
     <tr> 
     <td width="20%"> </td> 
     <td width="40%"> </td>
     <tr> 
    <td><b><h2></h2>Login:</td>
     <tr><td>USER NAME&nbsp&nbsp<input type="text" name="name"></td></tr>
    <tr><td>PASSWORD&nbsp&nbsp<input type="password" name="pw"></td></tr> 
    <tr><td><input type="button" name="submit" value="LOGIN" onclick="return validate()";> </td>
     </tr>  </tr>
    </table> 
    </form> 
    </body> 
    </html> 

现在它应该可以工作了。

你的控制台告诉你任何错误了吗?如果用户点击提交按钮,表单将发送消息,在这段代码中,当用户点击按钮时,将运行javascript中的validate()函数。javascript不允许你的表单提交!@Kermani这太错误了,如果所有条件都满足了怎么办?你看到
document.form1.submit()了吗
在验证函数的末尾?@asprin是的,您是对的
<form .... enctype="multipart/form-data"  ">
------------------------------------------^ you have extra double-quote
<form action="Authenticate1.php" method="post"  name="form1" id="form1" enctype="multipart/form-data">
<input type="button" name="submitBtn" value="LOGIN" onclick="return validate()";>