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("The Address1 field is too long"
return;
}
if (document.frm_lookup.text2.value.length > 33)
{
alert("The Address2 field is too long"
return;
}
if (document.frm_lookup.text3.value.length > 33)
{
alert("The Address3 field is too long"
return;
}
if (document.frm_lookup.text4.value.length > 33)
{
alert("The Address4 field is too long"
return;
}
document.frm_lookup.target = "";
document.frm_lookup.action = "blank.htm";
document.frm_lookup.submit();
}
</script>
</head>
<body>
<form name="frm_lookup" method="post" action="blank.htm">
<input type="text" name="text1" size="30" value="">
<input type="text" name="text2" size="30 value=""">
<input type="text" name="text3" size="30" value="">
<input type="text" name="text4" size="30" value="">
<input type="button" name="useme" value="use" onClick="checklength('Add1.value','Add23.value','Add4.value','Add5.value')">
</form>
<form name="frm_lookup" method="post" action="blank.htm">
<input type="text" name="text1" size="30" value="">
<input type="text" name="text2" size="30" value="">
<input type="text" name="text3" size="30" value="">
<input type="text" name="text4" size="30" value="">
<input type="button" name="useme" value="use" onClick="checklength(Add1.value,Add23.value,Add4.value,Add5.value)">
</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!
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("The Address1 field is too long"
return;
}
if (document.frm_lookup.text2.value.length > 33)
{
alert("The Address2 field is too long"
return;
}
if (document.frm_lookup.text3.value.length > 33)
{
alert("The Address3 field is too long"
return;
}
if (document.frm_lookup.text4.value.length > 33)
{
alert("The Address4 field is too long"
return;
}
document.frm_lookup.target = "";
document.frm_lookup.action = "blank.htm";
document.frm_lookup.submit();
}
</script>
</head>
<body>
<form name="frm_lookup" method="post" action="blank.htm">
<input type="text" name="text1" size="30" value="">
<input type="text" name="text2" size="30 value=""">
<input type="text" name="text3" size="30" value="">
<input type="text" name="text4" size="30" value="">
<input type="button" name="useme" value="use" onClick="checklength('Add1.value','Add23.value','Add4.value','Add5.value')">
</form>
<form name="frm_lookup" method="post" action="blank.htm">
<input type="text" name="text1" size="30" value="">
<input type="text" name="text2" size="30" value="">
<input type="text" name="text3" size="30" value="">
<input type="text" name="text4" size="30" value="">
<input type="button" name="useme" value="use" onClick="checklength(Add1.value,Add23.value,Add4.value,Add5.value)">
</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!