如何不允许输入unicode字符? [英] How to not allow to type unicode characters?

查看:97
本文介绍了如何不允许输入unicode字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


无论如何,不​​允许用户在加拿大或美国输入用户的姓名,姓氏,地址的unicode字符.请注意,加拿大用户也可以使用法语字符.
谢谢


is there anyway to not allow users to type unicode characters for the name, last name, address of a user that is either in canada or USA. Please note than canada users can use French characters as well.
Thanks

推荐答案

不使用Unicode不会对您有帮助. (此外,不存在非Unicode字符之类的东西,但是您可能需要代码点子集(例如ASCII之类的东西),可能也不完全是您所需要的.)确定确切的内容您可以过滤掉一些字符.

这是一个代码示例:
Not using Unicode won''t help you. (Also, there is not such thing as non-Unicode characters, but you probably need code point subset, something like ASCII, also may be not exactly what you need.) Decide what exactly You can filter out some characters.

Here is one code sample:
<html>
   <head>
      <script type="text/javascript"><!--
         function filterDigits(eventInstance) { 
            eventInstance = eventInstance || window.event;
                key = eventInstance.keyCode || eventInstance.which;
            if ((47 < key) && (key < 58) || key = 45 || key == 8) {
               return true;
            } else {
               if (eventInstance.preventDefault)
                  eventInstance.preventDefault();
               eventInstance.returnValue = false;
               return false;
            } //if
         } //filterDigits
      --></script>
   </head>
<body">

<input type="text" onkeypress="filterDigits(event)"/>

</body>
</html>



注意:您还需要允许输入键码8(退格键).

—SA



Pay attention: you also need to allow key code 8 (backspace).

—SA


这篇关于如何不允许输入unicode字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆