Click to See Complete Forum and Search --> : textbox color changer


rjusa
11-26-2003, 12:39 AM
The following routine changes the 2nd textboxes color depending on the entry in the 1st textbox. It works just fine in IE but not in Netscape. Any suggestions?

<script language="JavaScript">
function validate() {
if (document.Form1.name1.value.length > 0)
document.Form1.int.style.background = '#0000ff';
}
</script>
</head>
<body>
<form name="Form1" method="post" action="">
<input type="text" name="name1" size="20">Name1
<input type="text" name="int" size="20">Initials
</form>
<input type="button" value="change" name="B1" onclick="validate()"></p>

Thanks,
Ron

fredmv
11-26-2003, 12:54 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<style type="text/css">
/*<![CDATA[*/
li { padding: 2px; }
/*]]>*/
</style>
<script type="text/javascript">
//<![CDATA[
function validate()
{
if(document.forms[0].elements[0].value.length > 0) document.forms[0].elements[1].style.background = '#0000ff';
return false;
}
//]]>
</script>
</head>
<body>
<form action="#" onsubmit="return validate();">
<div>
<ul>
<li><input type="text" size="20" /> Name1</li>
<li><input type="text" size="20" /> Initials</li>
</ul>
<input type="submit" value="Submit" />
</div>
</form>
</body>
</html>