Reputation: 67
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>
Upvotes: 0
Views: 25
Reputation: 780673
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">
Upvotes: 1