所有非数字数据均不受javascript函数的限制 [英] all non numeric data are not restricted by javascript function

查看:64
本文介绍了所有非数字数据均不受javascript函数的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已限制用户在html文本字段中写入非数字数据.我工作正常,除非我使用Shift +数字键它显示!@#$%^^& *()这些章程?这些字符将受到限制??

-------------------------------------------------
我曾经用过这样的代码..

I have restricted user to write non numeric data in html text field.I is working fine except if I use the shift+number key it is displaying !@#$%^^&*() those charters??How those characters will be restricted??

-------------------------------------------------
I have used code like this..

if((code >= 48 && code <= 57)||(code >= 97 && code <= 105))
       {
           event.returnValue=true;
           return;
       }



(这是该功能的一部分
)
否则
返回false .......................
...该功能已添加到文本字段的onkeydown事件中...
.......如果用户以某种方式输入这些字符,系统也不会崩溃..................



(this is a part of the function
)
otherwise
return false.......................
...the function is added in the onkeydown event of the text field...
.......And system will not crush if the the user somehow enters those characters..................

推荐答案

%^^& *()这些章程?如何限制这些字符?

-------------------------------------------------
我曾经用过这样的代码..
%^^&*() those charters??How those characters will be restricted??

-------------------------------------------------
I have used code like this..
if((code >= 48 && code <= 57)||(code >= 97 && code <= 105))
       {
           event.returnValue=true;
           return;
       }



(这是该功能的一部分
)
否则
返回false .......................
...该功能已添加到文本字段的onkeydown事件中...
.......如果用户以某种方式输入这些字符,系统也不会崩溃.........



(this is a part of the function
)
otherwise
return false.......................
...the function is added in the onkeydown event of the text field...
.......And system will not crush if the the user somehow enters those characters..................


好,您要知道的大事是您的代码需要处理服务器上的任何字符,如果它崩溃以获取非数字,那么任何人都可以使您的系统崩溃.除此之外,鉴于您没有告诉我们您的工作方式,我们不知道您还需要做些什么来进一步限制它.
Well, the big thing for you to know is that your code needs to handle any characters on the server, if it crashes to get a non number, then anyone can crash your system if they want to. Beyond that, given that you don''t tell us how you did what you''ve done, we have no idea what else you need to do to restrict it further.


可能是您可以使用某种onChange()处理程序来检查数据吗?

某种
May be u can use some kind of onChange() handler which checks data?

Some kind of
if (/^[0-9]+


这篇关于所有非数字数据均不受javascript函数的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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