jquery validate does not show error message -


i've searched similar questions , have found no joy. validation works, in terms of logic in send function, span following validated element not showing error message when invalid. i've tried passing in errorplacement, thing works if set so

$("#msgvalid").text($("#msg").attr("data-val-required")); 

the relevant html is

<form id="frmsend" style="margin-top:15px"> add comment: <div> <textarea id="msg" data-val="true" data-val-required="the comment cannot blank." placeholder="enter comment here" style="height:50px;width:300px"></textarea> <span id="msgvalid" class="field-validation-valid text-danger" data-valmsg-for="msg" data-valmsg-replace="true"></span> </div> <button type="button" onclick="send();" class="btn-default" style="margin-top:10px">send comment</button> </form> <script src="/scripts/jquery-1.10.2.js"></script> <script src="/scripts/bootstrap.js"></script> <script src="/scripts/respond.js"></script> <script src="/scripts/jquery.validate.js"></script> <script src="/scripts/jquery.validate.unobtrusive.js"></script> 

and relevant javascript is

<script type="text/javascript"> function send() { $("#frmsend").validate(); if (!$("#frmsend").valid()) { return false; } alert("would send"); } </script> 

you must have name attribute on every input element considered validation...

documentation:

the name attribute "required" input elements, validation plugin doesn't work without it.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -