2010-12-28 5 views
0

私はこのコードそれは.required、小文字だテキストボックスは必要等しい偽

$(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; 
} 

     }); 
    }); 

答えて

1

にfalseに等しい必要なテキストボックスを作るのですか、とあなたにも、あなたが扱っているので、さらにあなたのコードを簡素化することができますかブール値:

$(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

0

あなたはthisについて話していますか?

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

ありHTML5におけるDOM属性 'required'は –

+0

はい:)だが、私は –

+0

@Nick CraverはJavaScriptで= "false" を必要とするための一つの方法が必要です。私は参照を。私はHTML5について何かを読んでから:) – dierre

関連する問題