So I had another question on here of how I could find all the validation images on the view using JQuery. This worked, but it turns out that when we update our fields on the page, we don't com开发者_运维百科pletely remove the validation images, we wrap them in this:
<span style="display: none;" validationfor="ResetDayComponent.ResetBusinessDayConvention">
</span>
So instead of using this JQuery:
if ( $('img.validation').length ) // validation errors exist
{
alert("errors");
return;
}
How can I find ONLY the validation images that are actually user visible?
Thanks!
You can use the :visible
selector.
if ( $('img.validation:visible').length ) // validation errors exist
{
alert("errors");
return;
}
$("img.validation:visible")
http://api.jquery.com/category/selectors/visibility-filter-selectors/
精彩评论