ohboy21
ohboy21

Reputation: 4319

How to handle right-to-left text-input fields the right way?

I am working on a multilingual layout. What worries me is:

How to handle text-input the right way?

I've build a JSFiddle to explain my problem.

  1. If I just add dir="rtl", the words appear from right to left, but not each character
  2. If I add the CSS style for right-to-left, the included numbers are also turned around

How can i combine numbers and text, so a hebrew input is showing correctly?

Upvotes: 2

Views: 2977

Answers (1)

Bojan Petkovski
Bojan Petkovski

Reputation: 6933

You can try this solution from here

Example http://jsfiddle.net/0w5rydrL/1/

The html

<div class="text_direction" dir="rtl">
    <input type="text" onkeyup="rtl(this);" />
</div>

The javascript function

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

Upvotes: 4

Related Questions