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

风流意气都作罢 提交于 2019-12-04 04:54:10

问题


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?


回答1:


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);
    }
}


来源:https://stackoverflow.com/questions/26361649/how-to-handle-right-to-left-text-input-fields-the-right-way

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!