如何正确处理从右到左的文本输入字段? [英] How to handle right-to-left text-input fields the right way?

查看:131
本文介绍了如何正确处理从右到左的文本输入字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究多语言版式。我担心的是:


如何处理文字输入的正确方法?

我已经构建了一个 JSFiddle 来解释我的问题。


  1. 如果我只是添加 dir =rtl,这些词从右到左出现,但不是每个字符

  2. 如果我从右到左添加CSS样式,则包含的数字也会被转换




如何合并数字和文本,以便希伯来文输入正确显示



解决方案

您可以从 here



示例 http://jsfiddle.net/0w5rydrL/1/



html

 < div class =text_方向dir =rtl> 
< input type =textonkeyup =rtl(this); />
< / div>

JavaScript函数

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


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?

解决方案

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

这篇关于如何正确处理从右到左的文本输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆