Restrict other font type like "Symbol" in textbox

Posted by Robin_Ahuja2008 under jQuery on 12/17/2012 | Points: 10 | Views : 1363 | Status : [Member] | Replies : 2
Hello experts,
My problem is that i m having one textbox and i don't want to allow any special symbol in it
Even by copy and paste, eg. like in microsoft office 2007, we have font of type Kundli; write some content in ms word in kundli and copy it
paste it in textbox
Data will come like that

And that's what i don't want, please suggest any idea to solve this issue
Thanks !

Robin Ahuja


Posted by: Dotnetrajanikanth on: 12/17/2012 [Member] Starter | Points: 25

Create a css class having the property ime-mode:disabled; then add that class to the text box.

This will prevent you from alowing other fonts other than english.

Then for copy paste use onpaste = "return false"

<asp:TextBox ID="TxtSample" Runat="server" CssClass="ime" onpaste="return false;"/>




Robin_Ahuja2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ritu on: 12/20/2012 [Member] Starter | Points: 25

user following validation function
function CheckAlpha_name(strString) {
var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .";
var strChar;
var blnResult = true;
if (strString.length == 0) return false;

// test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++) {
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1) {
blnResult = false;
return blnResult;

function validation(){
if (CheckAlpha_name(document.getElementById('<%=txtFirstName.ClientID%>').value) == false) {
alert("First Name can contain only alphabets.");
return false;
return true;
call this function on button click like :
<asp:Button ID="btnSubmit" runat="server" Text="" CssClass="myButton" OnClientClick="javascript:return validation();"
OnClick="btnSubmit_Click" />

Robin_Ahuja2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response