<asp:TextBox ID="tb1" OnTextChanged="tb1_Changed" OnChange="tb1OnChange();" runat="server"></asp:TextBox>
<script type="text/javascript">
function tb1OnChange() {
if (typeof (Page_Validators) == "undefined")
return;
$find('tb1').style.color = tb1Required.isvalid ? "Black" : "Red";
}
I get error about style is not known.
I change that $find statement to:
if (tb1Required.isvalid)
document.getElementById("tb1").setAttribute('color', 'Black');
else
document.getElementById("tb1").setAttribute('color', 'Red');
Then I get error about tb1Required is not known. I guess JavaScript cannot access the tb1Required control directly like that. So I change it to
if (document.getElementById(tb1Required).isvalid)
and I get error about no such i ...
Go to the complete details ...