0

My validator doesn't work. It adds class "valid" when it's not. I am not sure if i used submit correctly but cannot make it work for hours now. Can anybody help this ?

This is my js code

$("#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."
            }
        }
    });

And my form is:

<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 Answer 1

1

The jQuery validate plugin matches the rules against the name attribute of the elements, not the id. You have no name in your <input>. Change it to:

<input id="kapakCode" name="kapakCode" placeholder="ör. D85C12Z5" type="text">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.