Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user error display

Status
Not open for further replies.

jjinx

Programmer
Oct 6, 2002
12
US
I am having trouble finding a way to change the text color
or maybe the background color of an input box.
I need to display errors when the user enters invalid information and I don't like using alert.

If there is any way I would like to know.
 
Hi,

I've used this same method of notifying users of form errors. It seems so much nicer then those ugly popups.

here is an example of changing an inputs background color. It works with everything except apparently you can't change the color of the inside of a checkbox (or maybe radio button also).

Code:
<html>
<body>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;test.htm&quot;>
<input ID=&quot;bob&quot; type=&quot;text&quot; onClick=&quot;change();&quot;>
</form>
<script>
function change(){
 document.getElementById('bob').style.backgroundColor = '#FF0000';
} 
</script>
</body>
</html>

You can apply the same idea to changing text color, just put your text inside a <span > and then change the text color style for the span by ID.

Have fun. Let me know if you need any more help.


Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top