I need to validate two text fields for null values, tried this piece of Jquery in my page,
$('#div1').hide();
$('#btn1').click(function(){
$('.class1').each (function() {
if($(this).val() == "") {
$('#div1').show();
}else {
$('#div1').hide();
}
});
It is validating only the first text field. Any help?
I think you should follow below approach
As per your code validation is done for only last input I guess.
Working demo