Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i change the color of multiple words in textbox. i don't want to rich text box,is it possible to change it. I need without reading the string,the color changes only in textbox.
i try this,but the color is change not in textbox,i want to change the color in textbox.
JavaScript
window.pageLoad = function () {
                var textbox = document.getElementById('<%= TextBox1.ClientID %>');
                var span = document.getElementById('txt');
                var text = textbox.value;
                var mytool_array = text.split(":");
               alert(text);
                if (mytool_array.length > 0) {
                 span.innerHTML = mytool_array[0] +""  + mytool_array[1] + "";         
                } }
            .mOver
 {
   color:Aqua; 
 }
<asp:TextBox ID="TextBox11" text="Asp:net" onblur="this.style.color='brown'" CssClass="disableCss" runat="server"  TextMode="MultiLine"><span style="color:Olive" id="txt"></span>
Posted
Updated 11-Nov-11 0:00am
v5

1 solution

Probably you need Richtextbox or any 3rd party control.

BTW do you want the textbox to be editable? If not(Read only) then you can try the following dirty trick(Yes with DIV).
HTML
<div style="border: 1px groove #000000; width: 350px;"><span style="color:red;">Red color text</span>  <span style="color:green;">Green color text</span>  <span style="color:blue;">Blue color text</span></div>
OUTPUT

Red color text  Green color text  Blue color text
 
Share this answer
 
Comments
G.chitrasen 11-Nov-11 22:57pm    
i don't want this span tag.i want the textbox to be editable,if user give the input in textbox. The span tag is used for read only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900