Hi list,


I have a simple page with a form a a Javascript formvalidation function. The first time when I fill in the fields errors like 'too long' are neatly displayed but once corrected the error messages remain.

Any help would be greatly appreciated.

The source is below.

j@n

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<html>
<head>
<meta name="description" content="JED:SP RACF">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">@import "./css/RACF.css";</style>

<title>RACF Access Check</title>
<script>
Code:
function valf(frm)
	{
	var elems=frm.elements,
	len=elems.length,
	skipped='submit,reset',
	isvalid=true;
	if(!valf.ret)
		{
		valf.ret={};
		}
//	var alfanum=/^[A-Za-z0-9]+$/
	for(var i=0; i < len; i++)
		{
		if(skipped.indexOf(elems[i].type) !=-1)
			{
			continue;
			}
		else
			{
			var td=document.getElementsByName(elems[i].name)[0].parentNode.parentNode.cells[2];
			td.style.color='#fff';
			td.style.textAlign='center';
			td.style.fontWeight='bold';
/*
the code below checks only for empty values,
so change the condition according to your needs
alert(elems[i].value.length);
*/
alert(i);
alert(elems[i].value);			
			if(!elems[i].value)
				{
alert('no value in if');
				td.innerHTML='<--  can not be empty';
				td.style.backgroundColor='Crimson';
				valf.ret[elems[i].name]=false;
				}
			
			else if(i == 0 || i == 2)
				{
				if (elems[i].value.length>8)
					{
					td.innerHTML='<--  too long';
					td.style.backgroundColor='Crimson';
					valf.ret[elems[i].name]=false;
					}
				}
			else if(i == 3)
				{
				if (elems[i].value.length>44)
					{
					td.innerHTML='<--  too long';
					td.style.backgroundColor='Crimson';
					valf.ret[elems[i].name]=false;
					}
				}
			else
				{
				td.innerHTML='OK';
				td.style.backgroundColor='Green';
				if(valf.ret[elems[i].name] != null)
					{
					delete(valf.ret[elems[i].name]);
					}
				}
			}
		}
	for(var k in valf.ret)
		{
		if(k)
			{
			isvalid=valf.ret[k];
			}
		}
	return isvalid;
	}
HTML Code:
</script>
</head>
<body>
<h1> RACF Access Check</H1>
<p></p><p></p>
<form name="RACF-Access" id="RACF-Access" onsubmit="return valf(this)">
<table border=1">
<colgroup>
<col width="*50">
<col width="*44">
<col width="*156">
</colgroup>
<tr>
<th>Description</th>
<th>Data</th>
<th>Information</th>
</tr>
<tr>
<td>Userid or group</td>
<td><input type="text" size="8" name="userid" autofocus></td>
<td type="text" id="e_id"></td>
<tr>
<td>Authority</td>
<td><select name="authority">
<option value="CHECK">CHECK</option>
<option value="READ">READ</option>
<option value="UPDATE">UPDATE</option>
<option value="CONTROL">CONTROL</option>
<option value="ALTER">ALTER</option>
<option value="EXECUTE">EXECUTE</option>
</select>
</td>
<td><DIV name="a_autr"</DIV</td>
</tr>
<tr>
<td>Class</td>
<td><input type="text" size="8" name="class"></td>
<td><DIV name=e_class"</DIV</td>
</tr>
<tr>
<td>Resource</td>
<td><input type="text" size="44" name="resource"></td>
<td><DIV name=e_resource</DIV</td>
</tr>
</table>
<p><img src="./images/jan Einst.Neubauten.jpg" alt="Einst. Neubauten" widtr="159" height="156" align="middle"/></p>
<input type="submit" value="Check Access">
</form>
</body>
</html>
<link href="./css/RACF.css" rel="stylesheet" type="text/css">