textbox required equal false

how do I make the textbox that required equal to false in this code

$(document).ready(function () {
        $("#<%= chkSpecialIntegration.ClientID %>").click(function () {
            if (this.checked) {
               $("#<%= ddlTypeSpecialIntegration.ClientID %>").show();

                document.getElementById('<%=txtTotalScoreDebit.ClientID %>').Required = false; }
else{
 $("#<%= ddlTypeSpecialIntegration.ClientID %>").hide();
 document.getElementById('<%=txtTotalScoreDebit.ClientID %>').Required = true;
}

        });
    });

Upvotes: 0

Views: 247

Answers (2)

dierre
dierre

Reputation: 7220

Are you talking about this?

$("#myform").validate({
  rules: {
    field: "required"
  }
});

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630569

It's .required, lower-case, and you can simplify your code further as well since you're dealing with booleans, like this:

$(document).ready(function () {
  $("#<%= chkSpecialIntegration.ClientID %>").click(function () {
    $("#<%= ddlTypeSpecialIntegration.ClientID %>").toggle(this.checked);
    document.getElementById('<%=txtTotalScoreDebit.ClientID %>').required = !this.checked;
  });
});

You can test it out here.

Upvotes: 1

Related Questions