Text Box style problem
We have a text box in a web page, which is used to modify the ip address. The text box style changes to the second box after editing the content in 开发者_Python百科it. How can I change the style back to the style of the first text box? We are using javascript in the client side. The web client is Internet Explorer 7.
The code snippet in ASP page which creates the text box is given below
<td style="height: 27px"><input type="text" id="txtIpAddressHost" name="txtIpAddressHost" value="" onchange="ValidateParameter(this);" onkeydown="this.style.backgroundColor='white'" disabled="disabled" maxlength="15" /></td>
The html before and after the changes are given below
Before Keypress
<input type="text" onkeydown="this.style.backgroundColor='white'" onchange="Validate(this);" maxlength="10" value="-30.000000" name="txtCoolSetPointCkt1" id="txtCoolSetPointCkt1">
After Keypress
<input type="text" onkeydown="this.style.backgroundColor='white'" onchange="Validate(this);" maxlength="10" value="-30.000000" name="txtCoolSetPointCkt1" id="txtCoolSetPointCkt1" style="background-color: white;">
css change
css change
{
background-color: white;
}
with CSS 2 you can achieve this only with CSS. Lets assume textbox has class ip-box.
input.ip-box { border:1px solid #333; }
//and when the input box has focus repeat the above rule
input.ip-box:focus { border:1px solid #333; }
But ie7 doesn't support this pseudo class. In that case you can do with javascript like
<input type="text" value="10.0.0.88" onfocus="javascript:this.style.border='1px solid #333' "/>
精彩评论