user131077
user131077

Reputation:

How to change textbox focus color?

How to change textbox focus color?

I am using different colored TextBoxes. Example dark violet, but keyboard focus is black. This is bad combination. How I can change TextBox focus to gain more visual contrast?

Upvotes: 1

Views: 3640

Answers (2)

Nic
Nic

Reputation: 732

If for web with javascript you can do something similar to the following

Javascript

function DoBlur(fld) 
{
    fld.className='normalfld';
}

function DoFocus(fld) 
{
    fld.className = 'focusfld';
}

Your CSS would have the following

.normalfld
{
    background-color: #FFFFFF;
}
.focusfld
{
    background-color: #FFFFCC;
}

and for your text box

then your text box will have the OnFocus and OnBlur events wired up.

<input type="text" onblur="DoBlur(this);" onfocus="DoFocus(this);" /> 

Upvotes: 1

Pbirkoff
Pbirkoff

Reputation: 4702

A presume you're working in WPF, so try setting the FocusVisualStyle-property.

More information about this can be found at: http://msdn.microsoft.com/en-us/library/bb613567.aspx

Upvotes: 4

Related Questions