So I have built some validation in Javascript and when a field has an error the div <div class="form-group">...</div>
becomes <div class="form-group has-error">...</div>
I then have a .btn-bar
div that contains the button for submitting the form. I have this hidden by default when the page loads:
$(document).ready(function(){
$('.registration-information').hide();
$('.btn-bar').hide();
});
I have a function to show the .btn-bar
:
function enableButtons(){
if(noErrors){
$('.btn-bar').slideDown();
}
}
Now obviosuly, the script above doesn't work. More specifically, the if
statement. My question, is how do I search for a div that has has-error
in the class name on the page? If there is one then the btn-bar does not show, if there isn't any then the btn-bar shows.