This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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: 60810
    
  65

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing textfield bgcolour upon entering data
 
Similar Threads
Spring Web-Flow Richfaces Client Side Validations
how to hide and show contents with struts2 div tag
j2me - RMS & appending textfield
retaining data on a form upon submit
Jsp code for retrieving dsts in s text field