0

I have a series of asp:textboxes (about 30) which I wanted to validate if they are empty (when the user goes to other textbox), when the users leave them empty (on blur) I have found tutorials on the net however it is specified only to a few textboxes, how can I achieve this?

<form id="form1" runat="server">

<asp:TextBox ID="txtLname" runat="server" placeholder="Last Name" BackColor="White" BorderColor="#C2C4CC" BorderStyle="Solid" Height="28px" Width="135px" title="Enter Your Last Name" onkeypress="return AllowAlphabet(event)" Enabled="False" TabIndex="4"></asp:TextBox>
1
  • Do you have Validators? Commented Nov 21, 2013 at 9:33

2 Answers 2

2

A little bit of your actual markup would come in handy, but from the information i have:

$('input, textarea').blur(function() {
if ($(this).val() == "") alert("empty!");
});

when the users leave them empty (on blur) I have found tutorials on the net

How is this a sentence?

Sign up to request clarification or add additional context in comments.

2 Comments

<asp:TextBox ID="txtLname" runat="server" placeholder="Last Name" BackColor="White" BorderColor="#C2C4CC" BorderStyle="Solid" Height="28px" Width="135px" title="Enter Your Last Name" onkeypress="return AllowAlphabet(event)" Enabled="False" TabIndex="4"></asp:TextBox>
the asp code is not interesting, how is the markup being output? does my code work for you?
0

Try this code:

function CheckEmptyCheckBox() {
        var empty = 0;
        $('input[type=text]').each(function(){
           if (this.value == "") {
               empty++;
               $("#error").show('slow');
           } 
        })
       alert(empty + ' empty input(s)')
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.