我有这个代码:
<PlaceHolder>
<div class="greenDiv">
<asp:TextBox ID="a" runat="server" />
</div>
<div class="greenDiv">
<asp:TextBox ID="ab" runat="server" />
</div>
</PlaceHolder>
我需要让用户知道他是否将文本框留空,我尝试过类似的方法..(不起作用)我错过了什么?
$('.greenDiv > input:text').blur(function () {
if (!$(this).val()) {
alert("fill this field");
}
});
最佳答案
尝试使用 input[type=text]
代替
$('.greenDiv>input[type=text]').blur(function () {
if (!$.trim($(this).val())) {
alert("fill this field");
}
});
关于javascript - 如何检查特定div下的特定文本框是否为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27507293/