10

Im workin on a web application , and I have a form on which I have a textbox that users must fill it using arabic language.
how can I control it using javascript ?
Changing the default language of the operting system to arabic will solve my problem.
How can i change the default language to arabic using javascript ???
and is it the best approch to do it??
Is their another method ?

3
  • Best you can do is setting dir="rtl" inside the textbox. Commented Dec 9, 2010 at 9:08
  • Did you try my solution? Commented Dec 9, 2010 at 9:15
  • 1
    @shadow : dir="rtl" will just change the direction..not the input language.. @Jani: im trying it now Commented Dec 9, 2010 at 9:25

5 Answers 5

5

Refer to this question and it will solve your problem pal Arabic text box

EDIT: Change the code to this

$().ready(function () {
    $("input#NameTextBox").attr("lang", "fa");
});
Sign up to request clarification or add additional context in comments.

6 Comments

Look what im tryin to do but still not workin $().ready(function () { $("input,textbox").each(function () { $("input[id$=NameTextBox]").attr("lang", "ar"); }); and i have in my form <asp:textbox id="NameTextBox" runat="server"/>
Did you add required js files(jquery and farsitype.js) to you page in the same order as I do?
yeah i did. <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script> <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
oh ok i forgot the farsitype...ill give a try
Another issue is that why do you add the duplicate reference to jquery? just add the minified or development file. you can use the development for debugging now and change it to minified when you publish it.
|
3

a better solution may be:

Farsi type java script code

Comments

0

If using jquery in your application is possible you may take a look at the jquery direction plugin. You may see it in action here.

1 Comment

$().ready(function () { $("#submitButton").click(function () { $("input[id$=NameTextBox]").setDirections( { direction: 'rtl', textAlign: 'right' }, true ); }); this is what ive tried ... am i workin right?
0

If you want to limit the characters entered into a text box there is no use to set the language of the operating system.

You can use a RegularExpressionValidator or a CustomValidator which checks the characters entered, and displays a message saying those characters are not allowed.

Or add some form of javascript which limits the same. You have to decide if you want to block characters as they are typed, or display a message.

1 Comment

i dont want to block characters or to display any message..i just want to change the input textbox to arabic dynamically..is it possible?
-1

You want to change the default language of the OS using JS? Never, ever, going to happen - your web page has absolutely no rights over the client machine.

As for making the page itself "be arabic", I really don't think there's anything you can do about this from a culture point of view, but in terms of merely making the page right-to-left there's a lot that needs to be done in terms of mirroring content, but you'll definitely want to know about direction. You're best bet for the rest is to deal with culture and cultural validation on the server-side but it's going to depend enormously on what exactly you're trying to force, e.g. actual language validation assumes things like dictionaries and grammar checking and that would be something you probably want to look at 3rd party solutions for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.