Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Sergey Alexandrovich Kryukov 27-Mar-12 23:06pm    
OP commented in reply to answers:

thank you guys for your quick reply

but none of the above works.

how can i take the char entered in my textarea and find if its hebrew with \u0590 \u05ff

???

i need that step by step help guys.


moses
Sergey Alexandrovich Kryukov 27-Mar-12 23:07pm    
Hm. I tested my code.
--SA

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:
JavaScript
$("#txt").keydown(function(event) {
    if ((event.key >= 'א') & (event.key <= 'פֿ'))
        alert("Sholom!");
});


(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
 
Share this answer
 
v4
Comments
Abhinav S 26-Mar-12 21:46pm    
5 of course.
Sergey Alexandrovich Kryukov 26-Mar-12 21:48pm    
Thank you, Abhinav.
(I fixed the code after your vote.)
--SA
Abhinav S 27-Mar-12 1:58am    
No problem. It was a good answer anyway. :)
Here[^] is the hewbrew character set that you can capture in your keydown event.
The unicode range is \u0590 to \u05FF.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 27-Mar-12 23:05pm    
Right, a 5.
--SA
Abhinav S 27-Mar-12 23:08pm    
Thank you SA.
moses12345 28-Mar-12 5:50am    
thank you guys for your quick reply

but none of the above works.

how can i take the char entered in my textarea and find if its hebrew with \u0590 \u05ff

???

i need that step by step help guys.


moses

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900