Jquery验证器插件不验证

时间:2017-01-30 21:31:06

标签: javascript jquery forms validation jquery-validate

我的验证器不起作用。当它不是时,它会增加“有效”类。我不确定我是否正确使用提交,但现在无法使其工作数小时。有人可以帮忙吗?

这是我的js代码

$("#codeForm").validate({
        rules : {
            kapakCode: {
                required: true,
                minlength: 8,
                maxlenght:8
            }
        },
        messages : {
            kapakCode: {
                required: "Bu alanı doldurmalısın.",
                minlenght: "Kapak altı kodunu eksik veya hatalı yazdın.",
                maxlenght: "Kapak altı kodunu eksik veya hatalı yazdın."
            }
        }
    });

我的表格是:

<form id="codeForm">
                        <ul class="lightContentList">
                            <li>
                                <span>Enter the code</span>
                                <div class="inputDiv">
                                    <input id="kapakCode" placeholder="ör. D85C12Z5" type="text">
                                </div>
                            </li>
                            <li>
                                <img class="captchaTest" src="img/captchaPlaceHolder.png">
                            </li>
                            <li><!--<a class="button greyBtn" id="formSubmit" href="javascript:;">DEVAM</a>--> <input type="submit"></li>
                        </ul>
                    </form>

1 个答案:

答案 0 :(得分:1)

jQuery validate插件根据元素的 def echoHeaderDirective: Directive0 = optionalHeaderValueByName("X-Echo-Header") flatMap { case Some(value) => respondWithHeader(RawHeader("X-Echo-Header", value)) case _ => pass } 属性匹配规则,而不是name。您的id中没有name。将其更改为:

<input>