5つのアイコンがあるフォームがあり、どれがクリックされたかを検証したいと思います。非表示のテキストボックスを追加して、その値をチェックするルールを作成することを考えました。これはフォームの送信で機能しますが、正しい画像をクリックするとエラーメッセージがクリアされる必要があります。現時点では、テキスト値がjavascriptによって変更された場合、検証は実行されません。これを行うためのより良い方法はありますか?
<form name="frmExperiment" id="frmExperiment" action="" method="post">
<img src="btn1.png" width="75" height="75" alt="continue" title="continue" onclick="frmExperiment.txtIconG.value=1" />
<img src="btn2.png" width="75" height="74" alt="information" title="information" onclick="frmExperiment.txtIconG.value=2" />
<img src="btn3.png" width="75" height="82" alt="refresh" title="refresh" onclick="frmExperiment.txtIconG.value=3" />
<img src="btn4.png" width="75" height="75" alt="home" title="home" onclick="frmExperiment.txtIconG.value=4" />
<img src="btn6.png" width="75" height="77" alt="stop" title="stop" onclick="frmExperiment.txtIconG.value=5" />
<input type="text" name="txtIconG" id="txtIconG" />
</form>
と
$.validator.addMethod("iconmatch", function (value, element) {
return value==1;
},
"That isn't the continue button"
);