Hi ,
I have a scenario in which i have four input fields in asp with the same name batchlist.
I have a button called add batch .
The user can add the batch by clicking the add batch button . out of the four asp input field there are some field which the user cannot leave blank . we can know that mandatory field by the SQL table by checking the Ismandatory field.
i want to validate it by writing a javascript so that i make sure user enter the field which are mandatory.
I have written the following code but it dosent work.
[CODE=javascript]function validateBatchNu mber(){
<% j = 1 %>
for(var i=0;i<document. form1.BatchFiel ds.length;i++)
{ alert(document. form1.BatchFiel ds[i].value)
<%
sql = "select * from batchcontrol where fieldID ='"& j &"' order by fieldID"
Rs.open sql,oConn
if trim(Rs("isMand atory")) = "1" then %>
if (document.form1 .BatchFields[i].value = "")
{
return false;
}
<% end if
j = j + 1 %>
}
return true;
}
[/CODE]
can anyone please help.
warm regards
I have a scenario in which i have four input fields in asp with the same name batchlist.
I have a button called add batch .
The user can add the batch by clicking the add batch button . out of the four asp input field there are some field which the user cannot leave blank . we can know that mandatory field by the SQL table by checking the Ismandatory field.
i want to validate it by writing a javascript so that i make sure user enter the field which are mandatory.
I have written the following code but it dosent work.
[CODE=javascript]function validateBatchNu mber(){
<% j = 1 %>
for(var i=0;i<document. form1.BatchFiel ds.length;i++)
{ alert(document. form1.BatchFiel ds[i].value)
<%
sql = "select * from batchcontrol where fieldID ='"& j &"' order by fieldID"
Rs.open sql,oConn
if trim(Rs("isMand atory")) = "1" then %>
if (document.form1 .BatchFields[i].value = "")
{
return false;
}
<% end if
j = j + 1 %>
}
return true;
}
[/CODE]
can anyone please help.
warm regards
Comment