Library code snippets

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

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Change Text Field Colors.

Leave a comment

Sign in or Join us (it's free).

Super Tal Always working hard!!

Related podcasts

  • jQuery in ASP.NET

    In this episode Chris Brandsma, Rick Strahl, Dave Ward, Bertrand Le Roy, Scott Koon, and Steven Harman discuss Microsoft's jQuery in ASP.NET announcement.This episode of the Alt.NET Podcast is brought to you by LLBLGen Pro, the most mature O/R mapper and code generator out there.Are you loo...

Events coming up

  • Dec 8

    December Silicon Valley Ruby Meetup

    Moffett Field, United States

    In a World of Middleware, Who Needs Monolithic Applications? by Jon Crosby With Rack emerging as the standard for composing web applications and services, most recently with Rails adoption, an architectural shift is taking place. Learn how to create next generation web services by reusing existing Rack middleware and supplementing with your own components and micro-frameworks like Sinatra. Bio : Jon likes music, the Open Web, Ruby, Erlang, Haskell, Objective-C, JavaScript and coffee.

Want to stay in touch with what's going on? Follow us on twitter!