JQueryを使用して、コンボボックスの選択値に応じてdivを表示/非表示にしています。この部分はうまく動作します。しかし、divを隠すとき、jquery関数はそのdivにある3つのRequiredFieldValidatorsも無効にする必要があります。私は、オンラインで探していたのだが、これは簡単に使用して達成することができるようだ:JQueryを使用してRequiredFieldValidatorsを無効にする
ValidatorEnable(ValidatorName, false);
しかし、私はRequiredFieldValidatorsはまだdiv要素が隠されているにもかかわらず、エラーが表示され、何も動作、そのメソッドを使用してみてください。
は私のjQueryの機能:<script type="text/javascript">
$(document).ready(function() {
var det = $("#SponsorDetails");
$(det).hide();
var all = $("#AllDetails");
$(all).hide();
$("#<%=SelectAccount.ClientID %>").click(function() {
//hide social worker and sponsor stuff
var value = $("#<%=SelectAccount.ClientID %> option:selected").val();
if (value == "Social_Worker") {
//show social worker stuff
$("#AllDetails").show("slow");
$("#SponsorDetails").hide("slow");
ValidatorEnable(document.getElementById("#<%=AddressValidator.ClientID %>"), false);
ValidatorEnable(document.getElementById("#<%=CityValidator.ClientID %>"), false);
ValidatorEnable(document.getElementById("#<%=CountryValidator.ClientID %>"), false);
} else if (value == "Sponsor") {
//show sponsor stuff
$("#AllDetails").show("slow");
$("#SponsorDetails").show("slow");
ValidatorEnable(document.getElementById("#<%=AddressValidator.ClientID %>"), true);
ValidatorEnable(document.getElementById("#<%=CityValidator.ClientID %>"), true);
ValidatorEnable(document.getElementById("#<%=CountryValidator.ClientID %>"), true);
}
});
});
</script>
誰かが私が検証グループまたはカスタムバリデータを使用することができます示唆したが、使用してjQueryのは、単にはるかに簡単なようだが、それは動作しませんなぜ私は知りません。
感謝を使用して...再び実行のために手動でバリデータを有効にするには、次のコードスニペットを使用することができ、それが働きました! – Matt