i create dynamic rows using this function :
-
function addRow()
-
{
-
var tbl = document.getElementById('applications');
-
var lastRow = tbl.rows.length;
-
var iteration = lastRow;
-
var row = tbl.insertRow(lastRow);
-
-
var cellRight = row.insertCell(0);
-
var el = document.createElement('input');
-
-
el.type = 'text';
-
el.name = 'application_name' + iteration;
-
el.id = 'application_name' + iteration;
-
el.size = 45;
-
el.className='cellData';
-
el.style.width='220px'
-
el.style.height='17px'
-
cellRight.appendChild(el);
-
var erSpan1 = document.createElement('span');
-
erSpan1.className='help'
-
erSpan1.innerHTML='<br><font color="white">empty</font>'
-
cellRight.appendChild(erSpan1);
-
el.onblur= function() {error_appname(el,erSpan1);}
-
-
the function error_appname is
-
-
function error_appname(obj,erSpan1)
-
-
{
-
alert("hi from appname")
-
var appname=obj.value
-
if (appname == "" )
-
{
-
erSpan1.innerHTML = "<br>please enter a application name"
-
return false;
-
}
-
else
-
{
-
erSpan1.innerHTML ="<br><font color='white'>validated</font>"
-
return true;
-
}
-
}
-
-
-
now this works well, on the "onblur" event..
what i want to do is , if the user directly click on submit... the function 'error_appname()' should be called for all the rows generated and if any of them return fasle the form should not be submitted and the error be displayed...
i try to call them like :
- function ValidateFunc()
-
{
-
iteration=document.getElementById("no_of_applications").value;
-
for ( i=2;i<=iteration;i++)
-
{
-
error_appname(application_name2 + i,application_name_error)
-
}
-
}
but can't call the function...
any ideas...