提交按钮应该验证所有的txtboxes,所以我写了这段代码,
但它不起作用,我还希望如果文本框不为空,那么它应该回发并且应该调用onclick,否则不会
function submit() {
for( var i = 0, t = document.getElementsByName( "txt" ), l = t.length; i < l; i++ )
if( t[i].value)
return true;
return false;
}
.aspx
<asp:TextBox name="txt" runat="server" ID="email" CausesValidation="True"
ClientIDMode="Static" ValidationGroup="email" ></asp:TextBox>
<b>Password:</b><br />
<asp:TextBox ClientIDMode="Static" ID="pwd" runat="server" name="txt" TextMode="Password" CausesValidation="True"></asp:TextBox>
<asp:LinkButton ID="Submit" runat="server" CssClass="button" Text="Login"
onclick="Submit_Click" OnClientClick="submit()" CausesValidation="False" />