I ahve a form that has multiple text boxes populated from a DB through a For…Next loop. Here is the code (simplified),
<%
For x = 1 to 10
%>
<input type=”text” name=”qty_<%=x%>” size=”1″>
<%
Next
%>
Basically I have 10 text boxes named qty_1 through qty_10. I need a way using javascript to check that these boxes (at least one of them) has a value in it before the form is submitted. Here is what I have so far.
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
//** check and uncheck all item checkboxes
function CheckAll() {
for (var i=0; i<document.form1.elements.length;i++) {
var e = document.form1.elements[i];
var blnflag = 0;
if (e.name == ‘qty_’+[i]) {
if (e.value == “”){
blnflag = 1;
}
}
}
if (blnflag == 1){
alert (“you must filling at least one field”);
return;
}
}
// End –>
</SCRIPT>
I have onsubmit=”return CheckAll();” in the form element. I am not gettign any errors when the form loads but it does not do the needed check either.
Anyone know of a better way to check the value of these text boxes?
Thanks
Ian