I'm trying to write a small snippet of jQuery that validates my input fields. If they don't validate I want to write an error message to an empty <p> tag, only I can't seem to target it correctly. Can anybody see/explain where im going wrong?
$(".nextform").click(function() {
var empty = $(this).parent().find("li input").filter(function() {
return this.value === "";
});
if(empty.length) {
$(this).find('p.feedback').html('error');
}
});
<div>
<li><input type="text" /><br /></li>
<li><input type="text" /><br /></li>
<li><input type="text" /><br /></li>
<li><p class="feedback"></p>
<input type="submit" value="next" class="next" /></li>
</div>
<li>tags within a<div>tag