如何在我在克隆中使用的java脚本中的每一行进行单独验证以添加更多功能但我无法对每一行进行验证。这是什么?
帮帮我
var i = 0;
function cloneRow() {
var row = document.getElementById("clone");
var table = document.getElementById("data");
var selectIndex = 1;
var clone = row.cloneNode(true);
table.appendChild(clone);
clone.setAttribute("style", "");
}
function deleteRow(btn) {
var result = confirm("Do you Want to delete this ?");
if (result) {
var row = btn.parentNode.parentNode;
row.parentNode.removeChild(row);
}
}

<div class="row">
<div class="col-sm-12">
<div class="col-sm-7"></div>
<div class="col-sm-2">
<button type="button"class="btn btn-primary default btn-xs" onclick="cloneRow()" >add more...</button>
</div>
</div>
</div><br><br>
<div class="row" id ="close">
<div class="col-sm-4"></div>
<div class='col-sm-4'>
<Form id="NAME_VALUE" method="POST" >
<table class="table-striped" >
<tbody id="data">
<tr id ="clone" style="display:none;">
<td>
Name :<input type="text" name="INPUT_NAME" style="width:100px;" id="name" name="INPUT_NAME">
</td>
<td>
Value :<input type="text" name="INPUT_VALUE" style="width:100px;" id="value" name="INPUT_VALUE">
</td>
<td>
<button type="button"class="btn btn-primary default btn-xs" name ="delete" style="margin-left: 5px;" onclick="deleteRow(this);
return false;">
<span class="glyphicon glyphicon-remove-circle" style="text-align:center" ></span></button>
</td>
</tr>
<tr>
<td>
Name :<input type="text" name="INPUT_NAME" style="width:100px;" id="name" name="INPUT_NAME">
</td>
<td>
Value :<input type="text" name="INPUT_VALUE" style="width:100px;" id="value" name="INPUT_VALUE">
</td>
<td>
<button type="button"class="btn btn-primary default btn-xs" name ="delete" style="margin-left: 5px;" onclick="deleteRow(this);
return false;">
<span class="glyphicon glyphicon-remove-circle" style="text-align:center" ></span></button>
</td>
</tr>
</tbody>
</table><br>
<button type="button"class="btn btn-primary default btn-xs" style="margin-left: 5px;" onclick="submit_login();
return false;"> save.</button>
</Form>
</div>
</div>
&#13;
$(document).ready($.validator.addMethod("valueNotEquals", function (value, element, arg) {
return arg != value;
},
"Value must not equal arg."));
$(function () {
$("#NAME_VALUE").validate({
errorClass: "validation-error-class",
// Specify the validation rules
rules: {
INPUT_NAME: {
required: true,
maxlength: 64
},
INPUT_VALUE: {
required: true,
maxlength: 64
}
},
// Specify the validation error messages
messages: {
INPUT_NAME: {
required: "[your name ?]",
maxlength: "[Your name cannot exceed 64 characters]"
},
INPUT_VALUE: {
required: "[ value ?]",
maxlength: "[Your password cannot exceed 64 characters]"
}
},
errorElement: "div",
wrapper: "div",
errorPlacement: function (error, element) {
error.appendTo(element.parent("td"));
error.css('color', 'red');
error.css('text-align', 'center');
}
});
});
function submit_login( )
{
if ($("[id='name'],[id='value']").valid()) {
alert("Successfully saved");
}
}
&#13;
我想在每行或每个tr创建这种类型的验证,所以请帮助我..] 1] 1
我把这个放了,但如果我在一个文本字段中写入,每个验证都会消失..