Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me how to do validations on fields generated by cloning

Status
Not open for further replies.

n4s

Programmer
Nov 20, 2002
11
NZ
<script>
var rowCt = 1
function cloneRow(){
rowCt++
theRow=document.getElementById("row1").cloneNode(true)
theRow.childNodes[1].firstChild.name = "fName" + rowCt
theRow.childNodes[2].firstChild.name = "file" + rowCt
document.getElementById("fileTable").firstChild.appendChild(theRow)
}
</script>
<table id="fileTable">
<tr id=row1>
<td>File Name:</td>
<td><input name="fName1"></td>
<td><input type=file name="file1"></td>
</tr>
</table>
<input type=button onClick="cloneRow()" value="Another">
 
Personally,instead of using ".childNodes[1]" and ".childNodes[2]", I would use ".cells[1]" and ".cells[2]", as this will remove any errors generated by text nodes (i.e. whitespace), etc.

You would also need to set the row ID of the cloned row, which you can do using the rowCt variable you already have.

After that, there should be no difference to validating a cloned row than validating a "regular" row. Are you having specific difficulties?

Hope this helps,
Dan
 
Thank you Dan

I'll try as you said, and then I can post again if I get any difficulties.

Thank you,
SAHI.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top