如何在javascript中验证数字 [英] how to validate number in javascript

查看:55
本文介绍了如何在javascript中验证数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有文本框,不允许在第一个和第二个位置以0开头的数字编号长度为3.





例如

如果01输入它应该提醒。

如果输入001也应该提醒。



提前致谢。

Hi,
I have text box which will not allow a number starting with "0" in first and second positions number length is 3.


for example
if 01 entered it should give alert.
if 001 entered also it should give alert.

Thanks in advance.

推荐答案

您好b $ b

你能做什么由此,



Hi
You can do by this,

function IsNumeric(data)
{
if (data === parseInt(data))
            alert("data is integer")
        else
            alert("data is not an integer")
}


看起来像 Homework 。所以我会给你一个作为回报;)



首先阅读: 轻松学习正则表达式(RegEx) [ ^ ]



-KR
Looks like Homework. So I'm gonna give you one in return ;)

Read this first : Learn Regular Expressions (RegEx) with Ease[^]

-KR


这篇关于如何在javascript中验证数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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