判断2个输入框至少输入1个
<script type="text/javascript"> function check_input() { var name = document.getElementById("txtname"); var phone = document.getElementById("txtphone"); if ((name.value.length == 0) && (phone.value.length == 0)) { alert("请至少输入一个查询条件"); return false; } else return true; } </script> <p>用户姓名:<asp:TextBox ID="txtname" runat="server"></asp:TextBox></p> <p>手机号码:<asp:TextBox ID="txtphone" runat="server"></asp:TextBox></p> <asp:Button ID="btnsearch" runat="server" Text="查询" CssClass="btn" OnClientClick="return check_input()" onclick="btnsearch_Click"/>