现有table例如:<form id="formId" method="post">
<input type="text" name="card.id" class="required"/>
<input type="text" name="card.type" class="required"/>
<input type="button" name="addOneRow"/><table id="tid">
<thead>
<tr><td>ID</td><td>NAME</td><td>CODE</td></tr>
</thead>
<tbody></tbody>
<tfoot>
<tr style="disply:none">
<td><input name="person.id" type="text" class="required"></td>
<td><input name="person.name" type="text" class="required"></td>
<td><input name="person.code" type="text" class="required number"></td>
</tfoot>
</table>
</from>
tfoot相当于源,clone一份到tbody填写数据,
当form提交时通过remove掉tfoot中tr,(没有removeclass是因为考虑到tfoot中的input较多情况),但是card.id,card.name没有填写提交表单时同样remove掉了tfoot中tr(这是不希望的情况),问有没有from表单提交时放过某些添加了class的字段验证?例如:不验证tfoot中的person.id、person.name、person.code
<input type="text" name="card.id" class="required"/>
<input type="text" name="card.type" class="required"/>
<input type="button" name="addOneRow"/><table id="tid">
<thead>
<tr><td>ID</td><td>NAME</td><td>CODE</td></tr>
</thead>
<tbody></tbody>
<tfoot>
<tr style="disply:none">
<td><input name="person.id" type="text" class="required"></td>
<td><input name="person.name" type="text" class="required"></td>
<td><input name="person.code" type="text" class="required number"></td>
</tfoot>
</table>
</from>
tfoot相当于源,clone一份到tbody填写数据,
当form提交时通过remove掉tfoot中tr,(没有removeclass是因为考虑到tfoot中的input较多情况),但是card.id,card.name没有填写提交表单时同样remove掉了tfoot中tr(这是不希望的情况),问有没有from表单提交时放过某些添加了class的字段验证?例如:不验证tfoot中的person.id、person.name、person.code
在点击提交按钮的function中是先remove tfoot 再 submit form,也就是不论表单有没有验证通过,tfoot中的tr都romve掉了,现想:不remove tfoot中的tr,而是在submit时不验证这个tr(不去掉tr的class,这样就避免在clone他时再一一添加class)
<td><input name="person.name" type="text" class="required"></td>
<td><input name="person.code" type="text" class="required number"></td>
';function addRow(){
var tableBody = document.getElementById('myTableBody');
var newRow = document.createElement('tr');
newRow.innerHTML=trHtml ;
tableBody.appendChild(newRow);
}
//移掉必填项验证
function removeRequired(){
$("tfoot tr").each(function(i){
$(this).empty();
});
}
//新增页面保存
$("#save").click(function(){
$("input[name=densityRep.month]").parent().find("div").remove();
$.ajax({
type: "POST",dataType:"json",
url: "../dustAjax/checkDensityRepMonth.action",
data: "para1="+$("input[name=densityRep.month]").val(),
success: function(req){
if(req.result=="ok"){
$("#addForm").attr("action","../densityRep/save.action");
removeRequired();
$("#addForm").submit();
}else{
$("input[name=densityRep.month]").parent()
.append("<div>"+月份不允许重复!</div>");
}
}
});
});