点键无法使用ASCII字符 [英] Dot key is not working in ascii characters

查看:106
本文介绍了点键无法使用ASCII字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个JavaScript函数,该函数用于验证文本框以仅接受数字值,但是当我要编写34.45时,点在其中不起作用.
应该怎么解决.点的ASCII字符是46.
但是指定后,它不起作用.

Hello All,
I have a JavaScript function that is used to validate a text box to accept only numeric values but when i want to write 34.45 point is not working in it.
What should be the solution. ASCII character for point is 46.
But after specifying it ,it doesn''t work.

function isNumeric(keyCode)
{
   return ((keyCode >= 48 && keyCode <= 57) || (keyCode ==46)||(keyCode == 8))
}

推荐答案

这显然无法正常工作,它也将接受5.4.5.33. Javascript支持正则表达式,这就是您应该使用的.如果您使用的是ASP.NET,请使用正则表达式验证器,即使只是查看源代码并查看其工作原理也是如此.
This obviously will not work as if it does, it will accept 5.4.5.33, too. Javascript supports regular expressions, that''s what you should use. If you''re using ASP.NET, use a regex validator, even if it''s just to look at the source and see how they work.


这篇关于点键无法使用ASCII字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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