asp.net mvc - jQuery Validation on entire page -
i have webpage developed in asp.net mvc 3 , using jquery validator validate fields.
$.validator.setdefaults({ errorcontainer: "#validationsummary, #validationnotice", highlight: function (element, errorclass) { $(element).css("border", "1px dotted red"); }, unhighlight: function (element, errorclass) { $(element).css("border", "1px solid black"); } });
this give fields "red dotted border" when aren't valid.
i have text want show if fields valid in page .
<div class="readytosend" style="margin-top:50px;"> fields valid. </div>
so want hide "readytosend" if page isn't valid , show if of fields on page valid.
try this
$.validator.setdefaults({ errorcontainer: "#validationsummary, #validationnotice", highlight: function (element, errorclass) { $(element).css("border", "1px dotted red"); $(".readytosend").hide(); }, unhighlight: function (element, errorclass) { $(element).css("border", "1px solid black"); if($("#yourformname").validate().checkform()) { $(".readytosend").show(); } } });
make sure add display: none
on readytosend div
Comments
Post a Comment