I have a javascript that changes the textbox style upon focus and blur events.
I want the javascript to only change the style on the textbox if the textboxes style IS NOT set to “errorfld”
I have tried this but its not working
[CODE]
function DoFocus(fld) {
if (!(fld.classname == ‘errorfld’))
{
fld.className = ‘focusfld’;
}
}
On the page, i have 3 textboxes, 2 have their cssclass set to normalfld, and 1 has the cssclass set to errorfld, when I set focus to the box that is set to errorfld, the style still changes.
Here is the HTML Source from the browser
[code=html]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head><title>
</title>
<style type=”text/css”>
.normalfld
{
background-color: #FFFFFF;
border-top: 1.75px solid #999999;
border-bottom: 1.75px solid #999999;
border-left: 1.75px solid #999999;
border-right: 1.75px solid #999999;
}
.focusfld
{
background-color: #FFFFFF;
border-top: 2px solid #3399FF;
border-bottom: 2px solid #3399FF;
border-left: 2px solid #3399FF;
border-right: 2px solid #3399FF;
}
.errorfld
{
background-color: #FFFFFF;
border-top: 2px solid #FFB000;
border-bottom: 2px solid #FFB000;
border-left: 2px solid #FFB000;
border-right: 2px solid #FFB000;
}
</style>
</head>
<body onload=”fnOnLoad()”>
<form name=”form1″ method=”post” action=”Default.aspx” id=”form1″>
<script src=”Scripts/TBoxHighlighting.js” type=”text/javascript”></script>
<input name=”TextBox1″ type=”text” id=”TextBox1″ class=”normalfld” style=”width:219px;” />
<br />
<br />
<input name=”TextBox2″ type=”text” id=”TextBox2″ class=”normalfld” style=”width:219px;” />
<br />
<br />
<input name=”TextBox3″ type=”text” id=”TextBox3″ class=”[B]errorfld[/B]” style=”width:219px;” />
<br />
</form>
</body>
</html>
Any ideas whats wrong??