FCKeditor onBlur和按键检查非英文字符javascript,C#

问题描述:

我在C#中使用FCK编辑器v.2.6.6.我想检查用户是否在FCK内容中输入了非英语字符
用于我用作
的文本框

I am using FCK editor v.2.6.6 in C#. I want to check if user entered other than English character in FCK content
for a textbox i used as

<asp:TextBox ID="TextBox1" runat="server" Text=''<%# Bind("headline") %>'' Width="250px" Visible=true onkeypress ="return suppressNonEng(event)" onblur="suppressOnBluer(this)"></asp:TextBox>


我的JavaScript是


my javascript is

function  suppressNonEng(e)
 {
   var key;
   if(window.event)  key = window.event.keyCode;     //IE
   else  key = e.which;     //firefox

   if(key >128)  return false;
   else  return true;
 }

 function suppressOnBluer(e)
 {
     var s= e.value;
     e.value = '';
     for(i=0;i<s.length;i++)
          if (s.charCodeAt(i)<=128)
          {

           e.value += s.charAt(i);
             }
             if(s.length!=e.value.length)
             {
             alert('Other than english character are not supported')
             }

         
 }



如何也在FCK Editor V 2.6.6中检查内容?
请帮我解决这个问题.
在此先谢谢您.



How to check contents in FCK editor V 2.6.6 too ?
Please help me to resolve this.
Thanks in Advance.

请查看我为回应另一个类似问题而发布的代码示例,它将为您提供一个主意:
将KeyPress事件添加到自定义文本框控件 [ ^ ]

您的主要错误是alert.它将使您的客户疯狂.在每个键入的字符上!您有更好的方法:可以取消根据字符的代码点键入字符的操作.

—SA
Please look at my code sample I posted in response to another similar Question, it will give you the idea:
Adding KeyPress events to custom text box control[^]

You main mistake is alert. It will drive your customer crazy. On every character typed! You have mach better way of doing it: you can cancel the operation of typing the character based on its code point.

—SA