jQuery validation required( dependency-expression ) only 1 input validating
Posted
by
user331884
on Stack Overflow
See other posts from Stack Overflow
or by user331884
Published on 2011-01-07T00:51:17Z
Indexed on
2011/01/07
0:53 UTC
Read the original article
Hit count: 146
jquery-validate
<script type="text/javascript">
$(function () {
$("#form1").validate();
$("#survey1 .response").rules("add", { required: function () { return $('#choices').val() != '' } });
});
</script>
<form id="form1" runat="server">
<div id="survey1">
<asp:DropDownList ID="choices" runat="server">
<asp:ListItem Value="">--Select--</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
</asp:DropDownList>
<hr />
Response 1<br />
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"
Rows="6" CssClass="response"></asp:TextBox>
<hr />
Response 2<br />
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"
Rows="6" CssClass="response"></asp:TextBox>
</div></form>
Only the first textbox gets validated. Am I missing something?
© Stack Overflow or respective owner