[WEB4LIB] Colors in textboxes & textareas

Chris Gray cpgray at library.uwaterloo.ca
Tue Apr 30 16:39:57 EDT 2002


I don't believe this is possible since there is no way to distinguish the
background color of text from the background color of the textbox or
textarea.  As far as HTML is concerned those two backgrounds are the same
thing.

You might use something like the following:

<textarea style="text-decoration: overline">

or

<textarea style="text-decoration: underline">

and then spaces will be underlined or overlined.  (Although I notice that
for textboxes a space isn't underlined until a non-space character is
typed after it.)

On the other hand, I would think the prefered solution would be to take
out any trailing or leading whitespace automatically and then people
keying in data don't have to worry about it at all.

For example, in JavaScript the following would take trailling and leading
spaces off myString and change consecutive spaces between words to a
single space:

myString = myString.replace(eval(/^[ ]+/g), "");
myString = myString.replace(eval(/[ ]+$/g), "");
myString = myString.replace(eval(/[ ]+/g), " ");

There are even easier ways to do this in most other languages.

Chris Gray
Library Systems
University of Waterloo


On Tue, 30 Apr 2002, [Windows-1252] Fernando Gómez wrote:

> 
> We are using an HTML form to create/edit bibliographic records. I would like
> to avoid the possibility of accidentally entering unnecessary whitespace
> into a textbox or a textarea.
> 
> I know that using Javascript I could test if the text has that kind of
> whitespace, and show an alert message. But I would also like to use a visual
> clue, something like using a background color for the text, but *only* for
> the text, not for the whole textbox o textarea.
> 
> ¿Is that possible? The form is used in a restricted environment using IE, so
> I do not have to worry about browser compatibility.
> 
> Thanks in advance!
> 
> Fernando J. Gómez
> 
> Biblioteca Dr. Antonio Monteiro
> Instituto de Matemática de Bahía Blanca
> Universidad Nacional del Sur / CONICET
> Bahía Blanca - Argentina
> 
> 





More information about the Web4lib mailing list