Right to left Text HTML input

You can use the dir="rtl" on the input. It is supported.

<input dir="rtl" id="foo"/>

Here's what I can think of:

  • Use direction:RTL for the RIGHT alignment
  • Write a JavaScript handler attached to the event: "onkeyup", which performs the shifting of the entered character to the LEFT (doing some text processing).

function rtl(element)
{   
    if(element.setSelectionRange){
        element.setSelectionRange(0,0);
    }
}




<input type="text" name="textbox" style="direction:RTL;" onkeyup="rtl(this);"/>

This code will do.


Simply use this CSS, this will change your text field and cursor position from right to left.

input, textarea { 
 unicode-bidi:bidi-override; 
 direction: RTL; 
}