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

multiple forms with same name

Status
Not open for further replies.

madams

Programmer
May 2, 2002
8
GB
I have a page with multiple forms, these forms MUST have the same name.

I wish to validate some of the fields, only in the form which is submitted.

here is some example code

<html>
<head>
<title></title>

<script language='javascript'>
function checklength()
{
if (document.frm_lookup.text1.value.length > 33)
{
alert(&quot;The Address1 field is too long&quot;);
return;
}
if (document.frm_lookup.text2.value.length > 33)
{
alert(&quot;The Address2 field is too long&quot;);
return;
}
if (document.frm_lookup.text3.value.length > 33)
{
alert(&quot;The Address3 field is too long&quot;);
return;
}
if (document.frm_lookup.text4.value.length > 33)
{
alert(&quot;The Address4 field is too long&quot;);
return;
}
document.frm_lookup.target = &quot;&quot;;
document.frm_lookup.action = &quot;blank.htm&quot;;
document.frm_lookup.submit();
}
</script>
</head>

<body>

<form name=&quot;frm_lookup&quot; method=&quot;post&quot; action=&quot;blank.htm&quot;>
<input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;text2&quot; size=&quot;30 value=&quot;&quot;&quot;>
<input type=&quot;text&quot; name=&quot;text3&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;text4&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;button&quot; name=&quot;useme&quot; value=&quot;use&quot; onClick=&quot;checklength('Add1.value','Add23.value','Add4.value','Add5.value')&quot;>
</form>

<form name=&quot;frm_lookup&quot; method=&quot;post&quot; action=&quot;blank.htm&quot;>
<input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;text2&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;text3&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;text4&quot; size=&quot;30&quot; value=&quot;&quot;>
<input type=&quot;button&quot; name=&quot;useme&quot; value=&quot;use&quot; onClick=&quot;checklength(Add1.value,Add23.value,Add4.value,Add5.value)&quot;>
</form>

</body>
</html>


This code works with only one form on the page, however when there is more than one it says document.frm_lookup.text1.value is null or not an object

I have tried using 'this.frm_lookup' to no avail, any suggestions PLEASE!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top