如何知道用户在文本框中输入的数字或字符 [英] How to know user entered numeric or character in text box

查看:92
本文介绍了如何知道用户在文本框中输入的数字或字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何知道用户在文本框中输入的数字或字符

解决方案

查看此



< pre lang =xml> < script >

document.write(isNaN(123)+< br > );
document.write(isNaN(-1.23)+< br > );
document.write(isNaN(5-2)+< br > );
document.write(isNaN(0)+< br > );
document.write(isNaN(Hello)+< br > );
document.write(isNaN(2005/12/12)+< br > );

< / script >


使用IsNumeric函数例如: -



如果是IsNumeric( txtNAme.Text)= True然后

声明1

否则

声明2

结束如果


检查文本的长度;如果大于零,那么用户输入了什么,还有什么呢?


How to know user entered numeric or character in text box

解决方案

See this

<script>

document.write(isNaN(123)+ "<br>");
document.write(isNaN(-1.23)+ "<br>");
document.write(isNaN(5-2)+ "<br>");
document.write(isNaN(0)+ "<br>");
document.write(isNaN("Hello")+ "<br>");
document.write(isNaN("2005/12/12")+ "<br>");

</script>


Use IsNumeric function for eg:-

If IsNumeric(txtNAme.Text)=True then
Statement 1
Else
Statement 2
End If


Check the Length of the Text; if greater than zero, then the user entered something and what else could it be?


这篇关于如何知道用户在文本框中输入的数字或字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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