/    Sign up×
Community /Pin to ProfileBookmark

Set field Focus() background color

Right now when a user skips a mandatory field, I return their cursor to the required field. I WANT TO INCLUDE a Background color to the field in focus so it stands out better. This will greatly help our person who has vision loss due to macular degeneration. Can anyone help?

Here’s my error checking code to return the cursor to the missed field.

if (theForm.FirstName.value == “”)
{
alert(“Please enter a value for the “FirstName” field.”);
theForm.FirstName.focus();
return (false);
}

Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonJul 20.2004 — Try this:if (theForm.FirstName.value == ""){
alert('Please enter a value for the "FirstName" field.');

theForm.FirstName.focus();
theForm.FirstName.backgroundColor="#ff0000";
theForm.FirstName.onblur=function(){
this.backgroundColor="#ffffff";
}

return false;
}
I have also included an onblur event handler so that it will go back to normal once the user has filled in that field.
Copy linkTweet thisAlerts:
@LittlemizmeauthorJul 20.2004 — nope - didn't work in NE or IE....
Copy linkTweet thisAlerts:
@LittlemizmeauthorJul 20.2004 — Okay - just a small modification to get it to work. Had to add "STYLE" to code:

theForm.FirstName.style.backgroundColor="#A39A93";

Thank you for your quick and helpful assistance.!!!!!!!!!!!!!!!
Copy linkTweet thisAlerts:
@David_HarrisonJul 20.2004 — [i]Originally posted by Littlemizme [/i]

[B]Okay - just a small modification to get it to work. Had to add "STYLE" to code[/B][/QUOTE]
*headslap* I've made a few stoopid errors like this recently.[i]Originally posted by Littlemizme [/i]

[B]Thank you for your quick and helpful assistance.!!!!!!!!!!!!!!![/B][/QUOTE]
Happy to help. ?
Copy linkTweet thisAlerts:
@LittlemizmeauthorJul 20.2004 — Happy to receive :-)
Copy linkTweet thisAlerts:
@LittlemizmeauthorJul 20.2004 — Do you know how to change the Font Color?

I tried:

theForm.FirstName.style.font color="#800000";

doesn't work.
Copy linkTweet thisAlerts:
@David_HarrisonJul 20.2004 — Just this:theForm.FirstName.style.color="#800000";Like in CSS.

Generally putting spaces into things doesn't work.
×

Success!

Help @Littlemizme spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...