I have this code:
<PlaceHolder>
<div class="greenDiv">
  <asp:TextBox ID="a"  runat="server" />
</div>
<div  class="greenDiv">
  <asp:TextBox ID="ab" runat="server" />
</div>
</PlaceHolder>
I need to let the user know if he left a Textbox empty, I tried something like this.. (not working) What have I missed?
 $('.greenDiv > input:text').blur(function () {
   if (!$(this).val()) {
     alert("fill this field");
   }
 });
                Try using input[type=text] instead
$('.greenDiv>input[type=text]').blur(function () {
    if (!$.trim($(this).val())) {
        alert("fill this field");
    }
});
                        $('.greenDiv > input[type=text]').on('blur', function (e) {
  if (!$(e.currentTarget).val()) alert('fill this field');
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With