我有一個簡單的形式與6個文本框。 我使用Ajax來保存信息。 當我點擊編輯按鈕時,jQuery驗證器發現了錯誤但允許提交。 其實它只適用於最後的輸入!與jQuery驗證問題
我用類=「號fillone」來檢查他們進入只是數量,也進入6至少一個...
$('#edit_midterm').click(function() {
$("#edit_midterm_form").validate({
rules:{
queiz: {number:true, max:6,
seminar:{number:true, max:6,
tamrin:{number:true, max:6,
midterm:{number:true, max:6},
tahghigh:{number:true, max:6},
project:{number:true, max:6}
},
require_from_group: [1,".fillone"],
submitHandler: function()
{
$("#loading_edit").ajaxStart(function(){$(this).show();});
$("#loading_edit").ajaxStop(function(){$(this).hide();});
$.ajax({
type:"POST",
url:"course/term/ajax_mlist.php",
data:($("#edit_midterm_form").serialize()),
success:function(data){
if((data.result)=='true')
$("#result_edit").html(data.message);
},
dataType:"json"});
return false;
}
});
});
,這是我的表單:
<form name="edit_mid" action="" id="edit_midterm_form" method="post">
<input type="hidden" name="type" value="edit">
<input type="hidden" name="operation" value="yes">
<input type="hidden" name="ic" value="'.$id.'">
<table class="list" width="100%" border="0" align="center" cellspacing="1" cellpadding="5" dir="rtl">
<tr>
<th colspan="2">Edit Form</th>
</tr>
<tr>
<td width="100">Quize</td>
<td><span class="red_error"><input type="text" name="queiz" id="queiz" max="6" class="number fillone" value="'.$object->queiz_1.'"></span></td>
</tr>
<tr>
<td>Lecture</td>
<td><span class="red_error"><input type="text" name="seminar" id="seminar" max="6" class="number fillone" value="'.$object->seminar_3.'"></span></td>
</tr>
<tr>
<td>home Work</td>
<td><span class="red_error"><input type="text" name="tamrin" id="tamrin" max="6" class="number fillone" value="'.$object->tamrin_5.'"></span></td>
</tr>
<tr>
<td>Midterm</td>
<td><span class="red_error"><input type="text" name="midterm" id="midterm" max="6" class="number fillone" value="'.$object->midterm_2.'"></span></td>
</tr>
<tr>
<td>Search</td>
<td><span class="red_error"><input type="text" name="tahghigh" id="tahghigh" max="6" class="number fillone" value="'.$object->tahghigh_4.'"></span></td>
</tr>
<tr>
<td>project</td>
<td><span class="red_error"><input type="text" name="project" id="project" max="6" class="number fillone" value="'.$object->project_6.'"></span></td>
</tr>
<tr>
<td></td>
<td><input type="submit" id="edit_midterm" value="Edit" class="buttom_edit">
<img src="../template/icon/ajax_loader_1.gif" id="loading_edit">
<span id="result_edit"></span>
</td>
</tr>
</table></form>
這是你的代碼,正是因爲它是在你的計劃? – 2011-01-11 17:30:36