Jquery验证文件扩展名插件

Jquery验证文件扩展名插件,jquery,Jquery,我想要jquery验证插件的帮助。我用它来检查加载文件的扩展名。当扩展名不正确时,它会提示更改文件,当文件格式正确时,它会将其考虑在内。 该插件在我的代码中运行良好。问题是,当我点击提交按钮继续时,它是正确的文件,按钮不工作,我无法进入下一页。然而,我的页面之间有链接。你能帮我吗? <!DOCTYPE html> <html dir="ltr" lang="fr-FR" xmlns:th="http://www.thymeleaf.org"> <

我想要jquery验证插件的帮助。我用它来检查加载文件的扩展名。当扩展名不正确时,它会提示更改文件,当文件格式正确时,它会将其考虑在内。 该插件在我的代码中运行良好。问题是,当我点击提交按钮继续时,它是正确的文件,按钮不工作,我无法进入下一页。然而,我的页面之间有链接。你能帮我吗?


<!DOCTYPE html>
<html   dir="ltr"
    lang="fr-FR"
    xmlns:th="http://www.thymeleaf.org">
<head>
<meta   http-equiv="X-UA-Compatible"
    content="IE=10"/>
<meta   http-equiv="Content-type"
    content="text/html; charset=utf-8"/>
<meta   http-equiv="Expires"
    content="0"/>
<title th:text="${@environment.getProperty('spring.application.title') + ' - ' + serviceTitle} + ' - Livrer le DDX'"></title>
<link id="favicon"
    type="image/vnd.microsoft.icon"
    rel="shortcut icon"
    href="images/favicon.ico"/>
<meta   name="viewport"
    content="width=device-width, initial-scale=1"/>
<link   rel="stylesheet"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"  type="text/javascript"></script>    
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"   type="text/javascript"></script>
<link   id="mainCSS"    type="text/css" rel="stylesheet"    href="css/mainBS.css"/>
<link   id="workflowStageCSS"   type="text/css" rel="stylesheet"    href="css/workflow-stage.css"/>
<link   id="uploadDDXCSS"   type="text/css" rel="stylesheet"    href="css/uploadDDX.css"/>
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.validation/1.14.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
</head>
<body>                  <div class="articleBody">
                        <form  id="ddxForm" name="ddxForm"  method="POST"   enctype="multipart/form-data"   th:action="${@environment.getProperty('server.context-path') + 'uploadDDX'}" >
                            <p class="ddx-block"> 
                                <label  id="ddx-file-label"
                                for="ddx-file"  class="ddx-file-label"
                                >Fichier matlab(*):</label> <input id="ddx-file"
                                type="file"
                                name="ddx-file" 
                                class="ddx-file" th:required="true"/>                                   
                            </p><div><hr />                         
                                 <input id="ddx-next" name="ddx-next"
                                    type="submit" value="Continuer &gt;&gt;"/> <hr /></div>
                            </form></div>       
                        </article>
            </section>
        </section>
    </section>
    <script>
jQuery.validator.setDefaults({
  debug:true,
  success:"valid"
});
        $("#ddxForm").validate({
            rules:{
                "ddx-file":{
                    required:true,
                    extension:"m"
                }
            }
        });
</script>
</body>
</html>

菲希尔matlab(*):



jQuery.validator.setDefaults({ 是的, 成功:“有效” }); $(“#ddxForm”).validate({ 规则:{ “ddx文件”:{ 要求:正确, 扩展名:“m” } } });
来自调试选项的文档:

启用调试模式。如果为true,则不提交该表单,并且该表单是确定的 控制台上显示错误(将检查window.console 属性存在)。尝试在刚提交表单时启用 正在停止提交的验证


在测试失败案例后,尝试从setDefaults方法中删除“debug:true”。

为什么不能像这样使用ex:。而不是简单任务的验证器。这将不允许用户上传超过您指定的Hi John的文件。请阅读:并相应地更新您的问题。感谢Chris C的建议。我只需要从setDefaults方法中删除'debug:true'。