Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making a field highlighted before entry and un-highlighted after entry

Status
Not open for further replies.

Nate1749

Programmer
Nov 1, 2002
204
0
0
US
I have a form that currently has a few fields that need to be filled in. The problem we're running into is people are not entering information in all of the fields before sending us the form back. Making all of the fields required is one solution, however, we think our audience will not understand adobe's friendly pop-up (is there a way to customize error messages like in Access?).

The solution that was proposed was to have each field that needs to be filled in highlighted in yellow. Then after the field has data in it, to then un-highlight the field.

Is this possible? Thanks

-Nate
 
What you can do is set all of the fields to a certian color then add a javascript to change the color to a white bacground and black text after the fields onBlur event (action). See my example below.

Set action for field to javascript similar to below

var [VAR NAME] = this.getField("[FIELDNAME]");
[VAR NAME].fillColor = color.white;
[VAR NAME.borderColor = color.white;
[VAR NAME].textColor = color.blck;

- Replace [VAR NAME] with whatever you'd like to name the variable (no brackets)

- Replace [FIELDNAME] with the actual name of the field you are changing (no brackets). don't forget the quotes.

finished example based on the above:

var txtName = this.getField("name");
txtName.fillColor = color.red;
txtName.borderColor = color.black;
txtName.textColor = color.white;


Of course you can get fancy and change the color for the onFocus event the same way so the user will know what field they are filling in.

colors you can use (as in color.red)

black, ltGray, cyan, red, white, magenta, gray, dkGray, green, yellow, blue, transparent.

Good luck Aloha,
cg
 
You can also make your own custom colors by using the following code:

color.myColor = new Array("RGB",1,1,.62);
[VAR NAME].fillColor = color.myColor;
[VAR NAME].required = true; - makes the field required

Note that in the creation of the color array above, you take the true RGB numbers and divide each one by 255 to get the correct numbers.

You can also do it with CMYK values but I didn't look into what to divide the real numbers by.

Good Luck!
 
I tried this script and it said that the Var Name was undefined. I guess the 1st line doesn't define it. So, where would I go to define the Variable???
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top