Reputation: 17299
I want to create an input where numbers are input from right to left but the text is aligned right. I played with the dir attribute and text-align but have had no luck so far.
Here's a jsfiddle.
<input type="number" dir="rtl">
Upvotes: 3
Views: 6471
Reputation: 25
Here is the fiddle. https://jsfiddle.net/pbgjtgm8/
Use both direction and text-align properties.
<input class="right" type="number">
.right {
direction: rtl;
unicode-bidi: bidi-override;
text-align: left;
}
Upvotes: 0
Reputation: 1553
You need to handle this in css.
Your fiddle is updated here: https://jsfiddle.net/o0o0xq2s/4/, but the relevant code is:
HTML
<input class="right" type="number">
<br/>
I'd like the numbers to be left aligned so the digits grow to the right as I type :(
CSS
.right {
direction: rtl;
unicode-bidi: bidi-override;
}
There is also an older stack overflow example here: writing reverse in the textbox
Upvotes: 4
Reputation: 151
Do you need something that happens while entering values on a Calculator? If yes, try the following :
<tr>
<td align="right">Present Value:</td>
<td><input name="presentValue" type="text" size="20" value='<fmt:formatNumber value="${tvm.presentValue}" minFractionDigits="2" maxFractionDigits="2" />' >
</td>
</tr>
Upvotes: 0