We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 27,322 times

Related Categories

Change Text Field Colors

tlkelley

This function will change the colors of a form text box field by changing the style. The sample code in this example will change the background color to red and text color to white of a text box field if the value is negative. Simply call this function using an OnChange event and it will work fine. If the value is not negative then it sets the field to a standard white background with black text.

Do something like this in your text field properties:
OnChange=neg( this )

function neg( fld )
{
   fld.style.color = ( parseFloat(fld.value) < 0 ) ? 'white' : 'black';
   fld.style.backgroundColor = ( parseFloat(fld.value) < 0 ) ? 'red' : 'white';
}

Always working hard!!

Comments