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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate field by field problem

Status
Not open for further replies.

necta

Technical User
Mar 8, 2004
35
MY
I have this validate field by field problem. I used the method below but the error "textfields.length not an object" appeared.I tried on marks.length, it also gave the same error.What have I done wrong? I used on blur to validate each field. The 'elements.length' work in checkbox but not here.

Thank you

Necta

<!--
function numValidate(mrk)
{
var mrk;

for (i = 0; i < mrk.textfields.length; i++)
{
// check to see if the number field is blank
if (mrk.textfields.value == "")
{
alert("Please enter a number.");
mrk.textfields.focus();
return (false);
}
}
}
//-->
</script>


Do While NOT sRS.EOF
subjNo=subjNo+1
%>

<
<input type="text" name="marks<%=subjNo%>" id="marks<%=subjNo%>" type="text" size="4" value="<%=subjNo%>" maxlength="3" onblur="return numValidate(this)">


<%
sRS.moveNext
Loop
 
Have you tried testing
Code:
mrk.length
and
Code:
mrk[i].value
?????
 
I notice your function numValidate takes a parameter (mrk), however just inside the function your are declaring a variable of the same name which is probably over-riding it.

Doesn't look like you need the variable inside the function.

Regards,

Patrick
 
Hi
i tried mrk.value and it works now. However I couldn't figure out how to validate numeric between -1 and 100. Can u please give me some input?

rgrds,
Necta
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top