Changing color of text in a textfield

liunx

Guest
Hi,<br />
I want to change the color of the text in a text field if it doesn't meet some criteria. I would appreciate any suggestion as to how I could do it.<!--content--><input type="text" name="email" size="20"<br />
style="background-color: rgb(0,128,0); color: rgb(255,255,255)"><!--content-->Mark,<br />
Thanks. But ur code seems to make the whole text field colored instead of changing the text alone colored. I don't know if my code is wrong:<br />
<br />
<input type="text" name="scheduledstart<%=v%>" size="15" style="background-color: rgb(0,128,0); color: rgb(255,255,255)">&nbsp;&nbsp;<input type="button" value="Date" onClick="openChild('mycalendar.jsp?rv=<%=v%>&cv=1','win2')"><br />
<br />
Please have a look at it if u have time.<!--content-->If you wish to leave the background color the standard white, remove the background-color attribute and use whatever color you prefer for the text, like so:<br />
<br />
<input type="text" name="scheduledstart<%=v%>" size="15" style="color: #FF00FF"> <input type="button" value="Date" onClick="openChild('mycalendar.jsp?rv=<%=v%>&cv=1','win2')"><br />
<br />
substitue whatever color you prefer in place of #FF00FF, you can also use color names like red, green, blue, as long as it is a valid name. Or stick with the RGB format if you prefer.<br />
<br />
Regards,<br />
Kevin<!--content-->Thanks Kevin, it works as i wanted to.<!--content-->My question continues :<br />
I have to change the color now from javascript. Please have a look at this code<br />
<br />
testdate = new Date();<br />
testdate1 = testdate.getDate();<br />
<br />
mdate = m + "/" + d + "/" + y;<br />
<br />
opener.document.form2.scheduledfinish<%=rv%>.value = mdate;<br />
<br />
if (d > testdate1)<br />
<br />
opener.document.form2.scheduledfinish<%=rv%>.value.color = #FF00FF;<br />
<br />
This last line of code is where I need to change the color of the text from Javascript. This code is not the right one, and I would like to know how I could do it right.<!--content-->
 
Back
Top