P
please-answer-here
What is wrong with this code?
When I only assign the onblur call to one of the input fields everythings
work, but when I as belove use it on both fields I'll get an endless loop
with the alert messages repeating/replacing each other. I'll guess that the
problem/error must be somewhere in the focus expression but where is it?
******************* code ******************
<html>
<head>
<title>Test1</title>
<script>
function needed(fieldid) {
var form = document.form1;
if (fieldid.value.length == 0) {
alert('Field must not be empty '+ fieldid.name);
form.elements[fieldid.name].focus();
}
}
</script>
</head>
<body>
<form name="form1" action="cgi.asp" method="Post">
<input name="field1" type="text" onblur="needed(this) ">
<input name="field2" type="text" onblur="needed(this) ">
<input type="submit" name="sendit" value="push me">
</form>
</body>
</html>
****************** code ******************
When I only assign the onblur call to one of the input fields everythings
work, but when I as belove use it on both fields I'll get an endless loop
with the alert messages repeating/replacing each other. I'll guess that the
problem/error must be somewhere in the focus expression but where is it?
******************* code ******************
<html>
<head>
<title>Test1</title>
<script>
function needed(fieldid) {
var form = document.form1;
if (fieldid.value.length == 0) {
alert('Field must not be empty '+ fieldid.name);
form.elements[fieldid.name].focus();
}
}
</script>
</head>
<body>
<form name="form1" action="cgi.asp" method="Post">
<input name="field1" type="text" onblur="needed(this) ">
<input name="field2" type="text" onblur="needed(this) ">
<input type="submit" name="sendit" value="push me">
</form>
</body>
</html>
****************** code ******************