在asp:textboxes上的jquery onblur空文本框验证

时间:2022-11-13 19:45:26

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?

我有一系列的asp:textboxes(大约30个)我想验证它们是否为空(当用户转到其他文本框时),当用户将它们留空时(模糊)我在网上找到了教程但是它仅指定几个文本框,我该如何实现?

<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>

2 个解决方案

#1


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?

这句话怎么样?

#2


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

#1


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?

这句话怎么样?

#2


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