This is a migrated thread and some comments may be shown as answers.

[Solved] How can I change text color?

3 Answers 248 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nim
Top achievements
Rank 1
Nim asked on 30 May 2011, 08:01 PM
Hello,

In my view, I have:

<%= Html.Telerik().IntegerTextBox()
                             .Name("test")
                             .InputHtmlAttributes(new {style="width:30px;text-align:right"})
                             .Spinners(false).EmptyMessage("")  %>

Then I'm trying to write a Javascript to change the text color.  I've tried:

$("#test").data("tTextBox").element.style.color = "#336699";

but it's not working properly.

I wonder how I may change text color using Javascript?

Thank you!

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 31 May 2011, 09:13 AM
Hello Nim,

The tricky part in your scenario is that the NumericTextBox element consists of two elements - a textbox, which holds the real value, and a <div>, which holds the formatted value. The <div> is visible when the textbox is blurred. The textbox text is hidden when the textbox is blurred.

In order to change the text color while the component is blurred, please use:

$("#test").parent().find(".t-formatted-value").css('color', 'red');

In order to change the text color while the component is focused, please use your current approach plus the above line.

By the way, in order to have a right-aligned textbox, I recommend using the following:

Html.Telerik().IntegerTextBox().HtmlAttributes(new { @class = "ra" })

.ra {
    position: relative;
}
 
.ra  .t-formatted-value {
    left: auto;
    right: 0;
}


All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nim
Top achievements
Rank 1
answered on 13 Jun 2011, 07:35 PM
When I have a chance, I will run a quick test.
Thank you!
0
Harold
Top achievements
Rank 1
answered on 26 Aug 2011, 11:41 PM
Hi, I'm having the same problem and try to do this
.css

.currencyTextBox
   /*telerik.currencyTextBox style*/ {     position:relative;  } .currencyTextBox .t-formatted-value {     left:auto;     right0; }
vb.Class
<DisplayFormat(DataFormatString:="{0:C}")>
Public Property Monto As Decimal

View .vbhtml

@Html.Telerik.CurrencyTextBoxFor(Function(model) model.Monto).Spinners(False).Value(0).DecimalDigits(2).MinValue(0).HtmlAttributes(New With {.class = "currencyTextBox"}).InputHtmlAttributes(New With {.style = "text-align:right"}).CurrencySymbol(" ")
@Html.ValidationMessageFor(Function(model) model.Monto)

I set the HtmlAttribute and the InputHtmlAttribute, cause I need to align them to right when I'm editing and displaying too.

If you type an amount with 3 decimal digits the error doesn't display but if you type 2 decimal digits the error shows up like this


Thanks in advance
Tags
NumericTextBox
Asked by
Nim
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Nim
Top achievements
Rank 1
Harold
Top achievements
Rank 1
Share this question
or