如何在此代码中使所需的文本框等于false
$(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;
}
});
});
答案 0 :(得分:1)
它是.required
,小写,您可以进一步简化代码,因为您正在处理布尔值,如下所示:
$(document).ready(function () {
$("#<%= chkSpecialIntegration.ClientID %>").click(function () {
$("#<%= ddlTypeSpecialIntegration.ClientID %>").toggle(this.checked);
document.getElementById('<%=txtTotalScoreDebit.ClientID %>').required = !this.checked;
});
});
答案 1 :(得分:0)
您在谈论this吗?
$("#myform").validate({
rules: {
field: "required"
}
});