Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to remember background color in a form field

 
Yani Inay
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear helping hands:
I have a form with many text input fields and the fields are located in a table. Initially the text input fields have some kind of background color.
I use an external .js file to do edit check on the fields passing the form as parameter. If any fields are wrong, the .js file will change the background color of that field to red and display an error msg for user to correct the error. Then the user will try to submit the form again and the .js file will again do the edit check. If the newly corrected field has no error, I want to change its background color to its initial background color.
How do I remember that initial background color in javascript? Becaus now the input background color is red at this point.
Any help will be appreciated,
Soft Music
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yani Inay,

Declare a hidden variable in the form to store the current background colour of the form. Based on validation update the value of colour in the hidden variable.
That's how you will not loose the background value.
Vijay
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Yani Inay",
Nice try!
Except that your new name still doesn't match the JavaRanch naming policy.
In particular:
Obviously fictitious names, or improperly formatted names may be locked out

The naming policy was a decision made by Paul Wheaton (Javaranch creator). He says:
I want to maintain a professional exchange on JavaRanch so that corporate america won't feel embarassed to find employees spending time here.

Basically this means we try not to be militant about the naming policy, but there is a standard that has been set that we have decided to follow and we require you to register with a valid name.
thanks for your co-operation.
Dave
ps Sorry about the hard-line attitude , it's worth registering and sticking around tho, I promise!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic