tabindex不工作文本框哪个文本框是使用javascript限制字母表如何解决 [英] tabindex is not working textbox which textbox is restrict alphabets using javascript how to solve

查看:120
本文介绍了tabindex不工作文本框哪个文本框是使用javascript限制字母表如何解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的限制字母的java脚本



my java script for restrict alphabet letters

<script language="javascript" type="text/javascript">
        function CheckNumeric(e) {

            if (window.event) // IE
            {
                if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
                    event.returnValue = false;
                    return false;

                }
            }
            else { // Fire Fox
                if ((e.which < 48 || e.which > 57) & e.which != 8) {
                    e.preventDefault();
                    return false;

                }
            }
        }
    </script>









谢谢





thanks

推荐答案

< TAB>的关键代码是9,你抓住它。

不包括它你应该在哪里修理它。



要更好地问你更好的问题。



数字从密码48到57.

alpabeth从56到90



所以只包括if应该包围字母的数字,而不是所有的键。

如果你不想写信,请包括alpabet



The key code for the <TAB> is 9, you are catching that.
Excluding it form you're where should fix it.

To awnser you're question better.

The numbers go from keycode 48 to 57.
The alpabeth goes from 56 to 90

So to just include the numbers the if should surround just the alphabet, not all keys.
And if you just wan't letters, include the alpabet

if((e.which >= 48 && e.which <= 57)) {
   //This will only allow alphabet letters & all special keys 
   e.preventDefault();
   return false;
}

if((e.which >= 65 && e.which <= 90)) {
   //This will only allow numbers & all special keys 
   e.preventDefault();
   return false;
}


这篇关于tabindex不工作文本框哪个文本框是使用javascript限制字母表如何解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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