Validation Plug-in の「required (dependency-expression)」の説明からこの例を使用します。
$("#myform").validate({
rules: {
details: {
required: "#other:checked"
}
}, debug:true
});
$("#other").click(function() {
$("#details").valid();
});
以下の例でラジオボタン #guide が選択されている場合、テキスト入力を必須にしようとしています:
<input type="radio" id="outfitter" name="memtype" value="Outfitter" />Outfitter $125
<input type="radio" id="guide" name="memtype" value="Guide" />Guide $75
<input type="text" id="sponout" name="sponout" size="75" />
どこに置けばいいのかわからない
$("#other").click(function() {
$("#details").valid();
});
ルール検証コーディング内。