Click here to Skip to main content
Licence 
First Posted 11 Jan 2006
Views 47,813
Bookmarked 10 times

JavaScript Farsi TextBox

By | 11 Jan 2006 | Article
A TextBox for write Farsi

Introduction

On the internet some times we need get information from user in language other than English. for example we want the user type his name in Perisan language. there is two way to do this. First you can hope the user installed the farsi language in computer and change the language of windows to type.

This way have one Big problem and that is the Farsi Language that diffrent windows have is diffrent i mean. for Example the character codes in diffrent windows is diffrent.

The second way to handle both problems is using some javascript codes. in this way the user don't need to have Farsi Installed on machine. When the user type the code that user type convert to Farsi Language Unicode and write in the text box.

How do it ?

We must declare a function to convert typed character to Unicode.(Your page language must set to UTF-8).

function keyenter(field,e)
{
var key;
if (window.event)
   key = window.event.keyCode;
if (key>31)
  if (key<128)
  {
    if (window.event)
      window.event.keyCode=' !"#$%&#1548;&#1711;)(×+&#1608;-./0123456789:&#1603;,=.&#1567;@&#1616;&#1584;}&#1609;&#1615;&#1610;&#1604;&#1575;÷&#1600;&#1548;/&#8217;&#1583;×&#1563;&#1614;&#1569;&#1613;&#1601;&#8216;{&#1611;&#1618;&#1573;~&#1580;&#1688;&#1670;^_&#1662;&#1588;&#1584;&#1586;&#1610;&#1579;&#1576;&#1604;&#1575;&#1607;&#1578;&#1606;&#1605;&#1574;&#1583;&#1582;&#1581;&#1590;&#1602;&#1587;&#1601;&#1593;&#1585;&#1589;&#1591;&#1594;&#1592;<|>&#1617;'.charCodeAt(key-32);
  }
}
Note: Remember that the characters must not convert to unicode numbers and must look likes what you see here.

In the definition of textbox you must call OnKeyPress event to the function you have declared.

<input onkeypress="keyenter(this,event)" type="text" name="T1" size="20">

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Hamed J.I

Web Developer

Iran (Islamic Republic Of) Iran (Islamic Republic Of)

Member

I began programming with C/C++ when i was 15. Then try to learn VC++ but at the middle of my reading .NET came.
 
I began to read C# and VB.NET and also began designing basic websites by FrontPage and developed some websites for our school and some other companis.
 
Later learn Microcontroller and design some digital circuits with PIC microcontrollers for a industrial controller company.
 
As I learned SQL and ASP.NET developed some website such as news portals that are active now.
 
Now i'm a software student and teach programming in computer institues. And have my own job by getting projects from companies.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalasp.net javascript farsi textbox (IE,mozilla firefox,opera.....!!) [modified] Pinmemberamir movahedi7:52 2 Aug '09  
GeneralRe: asp.net javascript farsi textbox (IE,mozilla firefox,opera.....!!) PinmemberAfflatus2:31 22 Mar '11  
Generalit doesn't work in FireFox PinmemberMember #307324719:37 18 Feb '07  
Generalit doesn't work in FireFox PinmemberMember #307324719:36 18 Feb '07  
QuestionHow to change keys [modified] Pinmembermethod0078:03 6 Aug '06  
AnswerRe: How to change keys PinmemberActive-y16:38 10 May '07  
GeneralRe: How to change keys Pinmembermethod00716:50 10 May '07  
Generalfarsi textbox Pinmemberptvce0:20 15 May '06  
GeneralRe: farsi textbox PinmemberHamed_ji3:09 21 May '06  
GeneralRe: farsi textbox Pinmemberptvce19:40 21 May '06  
GeneralRe: farsi textbox [modified] PinmemberHamed_ji2:17 22 May '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 11 Jan 2006
Article Copyright 2006 by Hamed J.I
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid