Home > ASP.Net, Javascript > Allow Arabic Characters Only With TextBox Using Javascript

Allow Arabic Characters Only With TextBox Using Javascript


Hi all,

try this example to Allow Arabic Characters Only With TextBox Using Javascript

<script language="javascript" type="text/javascript">
// Allow Arabic Characters only
function CheckArabicCharactersOnly(e) {
var unicode = e.charCode ? e.charCode : e.keyCode
if (unicode != 8) { //if the key isn't the backspace key (which we should allow)
if (unicode == 32)
return true;
else {
if ((unicode < 48 || unicode > 57) && (unicode < 0x0600 || unicode > 0x06FF)) //if not a number or arabic
return false; //disable key press
}
}
}
</script>

With TextBox Control

<asp:TextBox ID="txt_FirstName" runat="server" Width="300px" MaxLength="20" onkeypress="return CheckArabicCharactersOnly(event);"></asp:TextBox>

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net, Javascript
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: