unreal1969
Programmer
Hi ther I'm trying to validate some text boxes according to state of checkboxes.
So of the start all text boxes start off as disabled now if a checkbox is clicked then the textbox is enabled and a value must be entered. On form submit I need to valiadte that at least one checkbox is clicked and the corresponding textbox has a value. But I'm having a litle bit of a hard time with this, can anybody help me.
I keep getting this error "'checked' is null or not an object"
here is my code
function checkWholeForm( frm )
{
var anyChecked = false;
theCount = parseInt( frm.count.value )
for ( var i = 0; i <= theCount; ++i )
{
var cb = frm.elements["enbl_" + i];
if (cb.checked)
{
anyChecked = true;
var py = frm.elements["payamount_" + i];
var amt = parseFloat( py.value );
if ( py.value == "" || isNaN(amt) )
{
alert("You didn't enter a valid payment amount in one of your clients"
return false;
}
}
}
if ( ! anyChecked )
{
alert("You must check at least one of the boxes."
}
return anyChecked;
}
<form action" method="post" name="payment" onSubmit="return checkWholeForm(this);">
<%for cnum = 0 to ubound(Arr_Clients,2)
<tr bgcolor="<%=bgcolor%>">
<td align="center"><p class="medtext"><%=Arr_Clients(2,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(3,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(11,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(12,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(13,cnum)%></p></td>
<td align="center"><input name="enbl_<%=cnum%>" onClick="enable(this,<%=cnum%>);" type="checkbox" > </td>
<td align="center"><input name="payamount_<%=cnum%>" readonly onBlur="calc(this.value);" type="text" size="8" ></td>
</tr>
<input type="hidden" value="<%=Arr_Clients(0,cnum)%>" name="userid">
<%next%>
<input type="hidden" value="<%=cnum%>" name="count">
</form>
So of the start all text boxes start off as disabled now if a checkbox is clicked then the textbox is enabled and a value must be entered. On form submit I need to valiadte that at least one checkbox is clicked and the corresponding textbox has a value. But I'm having a litle bit of a hard time with this, can anybody help me.
I keep getting this error "'checked' is null or not an object"
here is my code
function checkWholeForm( frm )
{
var anyChecked = false;
theCount = parseInt( frm.count.value )
for ( var i = 0; i <= theCount; ++i )
{
var cb = frm.elements["enbl_" + i];
if (cb.checked)
{
anyChecked = true;
var py = frm.elements["payamount_" + i];
var amt = parseFloat( py.value );
if ( py.value == "" || isNaN(amt) )
{
alert("You didn't enter a valid payment amount in one of your clients"
return false;
}
}
}
if ( ! anyChecked )
{
alert("You must check at least one of the boxes."
}
return anyChecked;
}
<form action" method="post" name="payment" onSubmit="return checkWholeForm(this);">
<%for cnum = 0 to ubound(Arr_Clients,2)
<tr bgcolor="<%=bgcolor%>">
<td align="center"><p class="medtext"><%=Arr_Clients(2,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(3,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(11,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(12,cnum)%></p></td>
<td align="center"><p class="medtext"><%=Arr_Clients(13,cnum)%></p></td>
<td align="center"><input name="enbl_<%=cnum%>" onClick="enable(this,<%=cnum%>);" type="checkbox" > </td>
<td align="center"><input name="payamount_<%=cnum%>" readonly onBlur="calc(this.value);" type="text" size="8" ></td>
</tr>
<input type="hidden" value="<%=Arr_Clients(0,cnum)%>" name="userid">
<%next%>
<input type="hidden" value="<%=cnum%>" name="count">
</form>