Change Text Field Colors

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 )
{ = ( parseFloat(fld.value) < 0 ) ? 'white' : 'black'; = ( parseFloat(fld.value) < 0 ) ? 'red' : 'white';

You might also like...


Super Tal Always working hard!!


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Walking on water and developing software from a specification are easy if both are frozen.” - Edward V Berard