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';
}
Comments