Jb Meris
Jb Meris

Reputation: 145

jquery onblur empty textbox validation on asp:textboxes

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>

Upvotes: 0

Views: 1052

Answers (2)

Indranil.Bharambe
Indranil.Bharambe

Reputation: 1498

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)')
    }

Upvotes: 0

Alex
Alex

Reputation: 10226

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?

Upvotes: 2

Related Questions