Jared
Jared

Reputation: 3892

How to Fix the Cursor Position on Text Input

I'm working on entering dollar amounts into a text input field. Is there a way when I have direction set to RTL that I can maintain the cursor to be at the farthest right position and keep it there?

<input type="text" id="textArea">

CSS:

#textArea {
direction:RTL;}

This just starts the cursor on the right, but when you type it still moves in the standard fashion. Any help would be appreciated.

Upvotes: 0

Views: 4497

Answers (3)

Amorfus
Amorfus

Reputation: 11

Add another attribute to your input that looks something like this:

onkeyup="rtl(this);"

Upvotes: 0

Dylan Corriveau
Dylan Corriveau

Reputation: 2557

Another solution is to use the dir attribute

<input type="text" dir="rtl" id="textArea">

Upvotes: 0

Jmh2013
Jmh2013

Reputation: 2777

Since you are dealing with text inside of an input, just use text-align: right;

#textArea{
    text-align: right;
}

Upvotes: 3

Related Questions