I have this function below
function checkLength(fie ld, nextField)
{
var letters = document.form1. elements[field].value.length +1;
if (letters <= 2)
{document.form1 .elements[field].focus()}
else
{document.form1 .elements[nextField].focus()}
}
And i call it from here:
<form name="form1" method="POST" action="addComp uter.php"
ONSUBMIT="retur n ValidateForm(th is)">
Hardware Ethernet
<input type="text" name="hardwareE therneta" maxlength=2 size=1
ONKEYUP="checkL ength('1','2')" >
</form>
My problem is that I have another form on a different page:
<form name="form2" method="POST" action="addComp uter.php"
ONSUBMIT="retur n ValidateForm(th is)">
Hardware Ethernet
<input type="text" name="hardwareE therneta" maxlength=2 size=1
ONKEYUP="checkL ength('1','2')" >
</form>
When the call to check length from form2, it fails as document.form1
isn't an object. How do I need to alter the function keeping the 2
form names different to get the function to work ok?
Help greatly appreciated, sorry newbie!!!!