标签:
今天做了一个项目,美工做好后放在了form中(没有加runat=server),由于用到了服务器控件,所以这里要加,否则报错,关键一段div代码是:
<form id="form_register1" runat="server" name="form_register1"> <%--action="#" method="post">--%>
<div>用户名:<input type="text" id="txtUser" runat="server" name="txtUser" /></div>
<div>密 码:<input type="password" id="txtPass" runat="server" name="txtPass" /></div>
<div class="rbPorC">
<asp:RadioButtonList ID="rbList" runat="server" RepeatDirection="Horizontal"
Width="130px" >
<asp:ListItem Value="0">个人</asp:ListItem>
<asp:ListItem Value="1">单位</asp:ListItem>
</asp:RadioButtonList> </div>
<div><asp:Button ID="Button1" CssClass="next_step_register" runat="server"
OnClientClick="return chk_form_register2(‘#form_register1‘)" Text="登录"
onclick="Button1_Click" /></div>
<%--<div class="next_step_register" onclick="chk_form_register1(‘#form_register1‘)">登录</div>--%>
</form>
js代码是:
function chk_form_register2(obj) {
if ($(obj).find("#txtUser").val() == "" || $(obj).find("#txtPass").val() == "" || (!$(obj).find("input[type=radio]").is(":checked"))
) {
alert("请填写完整");
return false;
}
js代码其中已经return false了,可是调试时,也 allert了,可是提示后就自动提交;解决是在OnClientClick="return chk_form_register2(‘#form_register1‘)",加上return,也就是
return chk_form_register2
标签:
原文地址:http://www.cnblogs.com/wanshutao/p/4285420.html