我有一个带有单选按钮的基本表格。即使在单击“td”时检查收音机的“td”中,我也有一个 onclick。单击“td”时,错误消息不会隐藏。它仅在单击实际按钮时隐藏。这是我的代码。有任何想法吗?我将 jquery 文件存储在本地。
<html>
<head>
<script src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#myform").validate({
errorPlacement: function(error, element) {
error.appendTo(element.parent("td").prev("td") );
},
debug:true
})
});
</script>
</head>
<body>
<form id="myform" action="/login" method="post">
<table border="1">
<tr>
<td width="30%">Attribute 1<br /></td>
<td width="10%" onclick="$(this).find('input:radio').attr('checked','checked');" /><INPUT type="radio" id="22121GRID" name="SPGRID_1" value="5" class="required" /></td>
<td width="10%" onclick="$(this).find('input:radio').attr('checked','checked');" /><INPUT type="radio" id="22121GRID" name="SPGRID_1" value="4" class="required" /></td>
<td width="10%" onclick="$(this).find('input:radio').attr('checked','checked');" /><INPUT type="radio" id="22121GRID" name="SPGRID_1" value="3" class="required" /></td>
<td width="10%" onclick="$(this).find('input:radio').attr('checked','checked');" /><INPUT type="radio" id="22121GRID" name="SPGRID_1" value="2" class="required" /></td>
<td width="10%" onclick="$(this).find('input:radio').attr('checked','checked');" /><INPUT type="radio" id="22121GRID" name="SPGRID_1" value="1" class="required" /></td>
</tr>
<tr><td><input type="submit" value="Submit" /></td></tr>
</table>
</form>
</body>
</html>