views:

209

answers:

2

I have a textbox that I want to the user to write something in it. I want that the default language there would be english. so if he pressed alt-shift before he came to my page and he is now on other language - when he'll come to my textbox it would change his language to english. Is it possible with javascript? how?

+1  A: 

This is not possible, but the thing is possible is check if the char is english. It will forbid chars from Chineese, Russian etc...

Eldar Djafarov
How would you prevent "characters from Dutch"? It's clear you can reject characters from non-Latin scripts, such as Cyrillic or CJK. But there are plenty of languages written in pure ASCII.
MSalters
I know i mentioned it:)
Eldar Djafarov
Not to mention that many characters which can't be done with pure ASCII are often written with pure ASCII anyway (Füße = FuBe, té = te).
Imagist
it would be simpler to allow what you want and disallow anything else, but it would be confusing to the user, as they would type and not understand why nothing in being written.
Nir Levy
@Djko So you would catch Russian but not Dutch? What's the point in a solution that only works on 50% of the world's languages?
Imagist
+3  A: 

I'm not sure what you mean by "pressing Alt-Shift". Are you referring to the keyboard layout switching hotkey in recent versions of MS Windows?

If yes, then the answer is "no". The layout switching is performed by the operating system and not accessible from Javascript. Which is a good thing, BTW. You would not want a webpage (or even a local application) to switch around your keyboard layout.

Incidentally, I do not understand why you would want to change the layout. If the user is comfortable with, say, a German or French layout, how does it help to change the layout?

Maybe you could elaborate on your problem. What are you trying to solve?

sleske
the customer wanted that when the customer would start writing things n the textbox. the language that he would have will be english (if he has it in his os)
Hagai