使用javascript检测进入文本区域的希伯来字符 [英] detecting hebrew chars entered into text area with javascript

查看:51
本文介绍了使用javascript检测进入文本区域的希伯来字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我拼命地试图找到一种简单的解决方案,我正在尝试实现

我需要知道用户是否在我的textarea中键入希伯来字符,而我无法弄清楚

请帮助!

moses

hello all,

im desperatly trying to find a solution to a simple thing i''m trying to implement

I need to know if a user types a hebrew char into my textarea, and i cannot figure this out

PLEASE HELP!

moses

推荐答案

可以使用事件onkeydown完成此操作.但是,我不建议您这样做,因为您需要使用事件结构来解决此问题.这就造成了浏览器兼容性问题.但是,可以解决此问题.请参阅:
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onkeydown [ ^ ].

由于这个问题,我建议您使用jQuery,它在设计时考虑了兼容性.此类问题已经对该库的用户透明地解决了.请参阅:
http://en.wikipedia.org/wiki/JQuery [ http://jquery.com/ [ ^ ].

以下是该解决方案的代码示例:
This could be done using the event onkeydown. However, I don''t recommend doing it because you need to use event structure to solve this problem; and this creates a browser-compatibility problem. However, this problem can be worked around. Please see:
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onkeydown[^].

Due to this problem, I would recommend using jQuery, which is designed with compatibility in mind. Such problems are already resolved transparently to the users of this library. Please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^].

Here is the code sample for the solution:


(" span>).keydown(函数(事件){ 如果((event.key> = ' א' )&(event.key< = ' פֿ'))) alert(" ); });
("#txt").keydown(function(event) { if ((event.key >= 'א') & (event.key <= 'פֿ')) alert("Sholom!"); });



(对不起,我可能会弄乱希伯来语字符,因为由于从左到右和从右到左的代码混合,很难输入它们,并且因为我不太了解如何考虑变音符号和连字上的条件,但我希望您有个主意:为Unicode代码点的有效范围编写条件.)

-SA



(Sorry, I might have messed up with Hebrew characters, because they are hard-to enter because of mixture of left-to-right and right-to-left code and because I don''t quite understand how to take into account the conditions on diacritical marks and ligatures, but I hope you got the idea: to write conditions for valid range of Unicode code points.)

—SA


此处 [ ^ ]是可以捕获的希伯来字符集在您的按键事件中.
Unicode范围是\ u0590到\ u05FF.
Here[^] is the hewbrew character set that you can capture in your keydown event.
The unicode range is \u0590 to \u05FF.


这篇关于使用javascript检测进入文本区域的希伯来字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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