I'm trying to set new value for asp.net control property when I check a checkbox.
In my case I have RegularExpressionValidator asp.net control and when I check the box I would have new value for the properties ErrorMessage and ValidationExpression.
I tried this code but did not work with me.
please help.
here is my code: ...............................................................................
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
function chkinput() {
if ($('#<%=chkIntphoneHome.ClientID %>').is(':checked')) {
$('#<%=REV_HomePhone.ClientID %>').attr('ErrorMessage', 'new msg');
$('#<%=REV_HomePhone.ClientID %>').attr('ValidationExpression', 'new exp');
}
}
</script>
<asp:CheckBox ID="chkIntMobileHome" runat="server" Style="position: absolute; top: 200px;
left: 535px;" Text="Internation Code" AutoPostBack="True"
/>
<asp:TextBox ID="txtHomePhone" runat="server" Style="top: 147px; left: 543px; position: absolute;
height: 22px; width: 128px" ></asp:TextBox>
<asp:RegularExpressionValidator ID="REV_HomePhone" runat="server" ErrorMessage="Please enter valid Home Phone"
Style="position: absolute; top: 177px; left: 476px; width: 226px;"
Display="Dynamic" ControlToValidate="txtHomePhone"
ValidationExpression="\d{3}?\d{3}\d{4}"></asp:RegularExpressionValidator>