Jquery check more input empty or not then

$('inputbyid').val().length == 0) {
$('.name').text('need to fill name');
}

$('inputbyid2').val().length == 0) {
$('.phone').text('need to fill phone');
}

$('inputbyid3').val().length == 0) {
$('.message').text('need to fill message');
}

I want to select ervery field when click on button display custom messages when about 3 input is not filled with custom text. Is seems work just always run the last script? I mean last check how to fix it? message check text write only but there have more before? hmm I wanna check one by one if name is filled check second phone?

Shouldn’t it be?

if( $('#inputbyid').val().length === 0 ) {
  $('.name').text('need to fill name');
}

Not sure how you are planning to actually deal with the events, is it a form?

Here is a quick Codepen, with some example code.

1 Like