/    Sign up×
Community /Pin to ProfileBookmark

textbox color changer

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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@fredmvNov 26.2003 — [size=1]&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

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

Success!

Help @rjusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...