GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Changing textfield bgcolour upon entering data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Changing textfield bgcolour upon entering data" Watch "Changing textfield bgcolour upon entering data" New topic
Author

Changing textfield bgcolour upon entering data

Rouven Withake
Greenhorn

Joined: May 05, 2008
Posts: 4
Hello everyone,

I have the following problem and was wondering if I could do this with JSP.

Basically I have a form with which I enter data into a database.
In the form are textfields. One of the textfields is for numbers only.
Upon entering numbers within the textfield I want it to change its background colour. For example: If its below 8 digits the bgcolour is yellow , if its exactly 8 its green and if its over 8 its red.

Is it possible to do this with JSP ?
If yes , how ?

Thanks for your help.

Cheers,

Rouven
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

Rouven,
You actually want to use JavaScript on the page to update the CSS for that textfield. I'll move this to our HTML forum where they are experts at that sort of thing.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I believe this is what you wanted:



You probably want to change the colors so they are lighter in color. I picked the basic red, green, and yellow color codes.

Eric
[ June 01, 2008: Message edited by: Eric Pascarello ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61305
    
  66

Originally posted by Rouven Withake:
Is it possible to do this with JSP ?

As has been pointed out, no.

JSP executes on the server in order to format the HTML page to send to the client. Once at the browser, client-side technologies such as JavaScript need to be used.

Perhaps this article will be helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rouven Withake
Greenhorn

Joined: May 05, 2008
Posts: 4
Thank you very much for your help

Rouven
 
GeeCON Prague 2014
 
subject: Changing textfield bgcolour upon entering data