我有一個包含5個圖標的窗體,我想驗證哪個窗體被點擊。我想添加一個隱藏文本框並寫出一個檢查它的值的規則。這適用於表單提交,但是我需要在單擊正確圖像時清除錯誤消息。目前,當文本值被javascript改變時,驗證不會被觸發。還有更好的方法嗎?Jquery驗證點擊了哪個圖像
<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"
);
不應該是'(值== 1)'? – mattsven 2011-03-17 19:57:49
返回值== 1將返回true或false。 – 2011-03-17 20:05:10