notyourmom
New Member
I have two javascript functions to change background color on enter and leave events.\[code\] function ColoronEnter() { var txt1 = document.getElementById("<%=txtID1.ClientID%>"); txt1.style.backgroundColor = "red"; } function ColoronLeave() { var txt2 = document.getElementById("<%=txtID1.ClientID%>"); txt2.style.backgroundColor = ""; }\[/code\]I am calling them as \[code\]<asp:TextBox ID="txtID1" runat="server" MaxLength="20" AutoCompleteType="FirstName" onfocus="ColoronEnter()" onblur="ColoronLeave()" ></asp:TextBox>\[/code\]It is working well. But I want to apply one javascript function to all my textboxes. I have tried something like \[code\] function onEnter(_input) { var input = _input; document.getElementById(input).style.backgroundColor ="yellow"; } function onLeave(_input) { var input = _input; document.getElementById(input).style.backgroundColor =""; } \[/code\]trying to call them as \[code\] <asp:TextBox ID="txtID2" runat="server" onfocus="onEnter(txtID2)" onblur="onLeave(txtID2)"></asp:TextBox> <asp:TextBox ID="txtID3" runat="server" onfocus="onEnter(txtID3)" onblur="onLeave(txtID3)"></asp:TextBox>\[/code\]It is throwing an error as \[code\]Microsoft JScript runtime error: Unable to get value of the property 'style': object is null or undefined.\[/code\]How can I call one function to all my textboxes. Thank in advance.