Reputation: 61
I have aspx page that have TextBox control for " User Arabic Name" I want to Allow user to type only arabic letters in textbox using JavaScript
Upvotes: 2
Views: 6291
Reputation: 11
"ذض ص ث ق ف غ ع ه خ ح ج دش س ي ب ل ا ت ن م ك ط ئءؤرلاى ةوزظ .acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
This string combined with above solution will allow users to type any english or arabic character with additional allow of a dot (.)
Upvotes: 0
Reputation: 2158
First you make text box like below :
<asp:textbox id="txtbxr" runat="server" onselectstart="return false" ondragstart="return false" onkeypress="return(KeyPressOrder(this,event))" onkeydown="(KeyPressOrder(this,event))" ></asp:textbox>
then add javascript method :
function KeyPressOrder(fld, e) {
var strCheck = '0123456789acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var whichCode = e.which ? e.which : e.keyCode;
if (whichCode == 13 || whichCode == 8 || whichCode == 9) return true;
key = String.fromCharCode(whichCode);
if (strCheck.indexOf(key) == -1)
return false;
return true;
}
Now you have to enter all arabic characters in strCheck like above example
Upvotes: 4