The fields in my form already validate. If they're invalid, there's a span class that appears and informs the user. Likewise if they're empty.
So I thought it would be easy enough to just check for the visibility of one of these classes.
Here's my script:
$(document).ready(function(){
if (($('.error').length) || ($('.empty').length)) {
function validateReview(){
document.getElementById('ReviewForm').submit();
}
} else {
function validateReview(){
alert("Please check fields and be sure to leave a review.");
}
}
};
And then the submit button in my form simply calls validateReview()
onclick.
But it's not working how I expected, I get this as an error "validateReview is not defined".
Did I declare validateReview()
incorrectly, or in a local scope maybe? BIG newb here so please be aware. I know enough only to get in trouble.