views:

203

answers:

2

How to hide a div if validation summary is available in javascript/Jquery.

+2  A: 
if(yourCondition){
  $("div#mydiv").hide()
}

what is validation summary?

mkoryak
Usually a validation summary is a div or block that contains all the error messages generated by a group of validation controls in some kind of list form.
Steve
any good ideas ???
George
IIRC, the validation summary is in a div. mkoryak's solution should work.
Steve
Set the validation summary's cssclass to say zzz. Then you can do mkoryak's sol'n. if (".zzz") { ...
Steve
A: 
var validationSummary = $('#<%= this.ValidationSummary.ClientID %>');
var myDiv = $('#myDiv');

if (validationSummary.length || validationSummary.is(':visible')) {
    myDiv.hide();
}

the cause for .is(':visible')is, that i don't know if an empty validationSummary renders the html-tags either or not. if not, you can leave out the .is()-check

Andreas Niedermair