如何验证TEXTBOX条目是仅数字形式还是特定数据类型? [英] How to validate a TEXTBOX entry to be only numeric or in a certain datatype?

查看:87
本文介绍了如何验证TEXTBOX条目是仅数字形式还是特定数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何验证TEXTBOX条目仅是数字形式还是特定数据类型?

How to validate a TEXTBOX entry to be only numeric or in a certain datatype?

推荐答案

用于数字验证-

For numeric validation -

Private Sub txt_KeyPress
(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) 
Handles txt.KeyPress

If Char.IsDigit(e.KeyChar) = False And Char.IsControl(e.KeyChar) = False Then
e.Handled = True
End If
End Sub


将此JavaScript添加到您的计算机中页.

通过发送ID调用此函数,您将获得数字文本框

函数EnterInteger(ID)
{
if(ID.value.length> 0)
{
ID.value = ID.value.replace(/[^ \ d] +/g,'''');
}
}

或使用\ d +(\.\ d {1,2})创建正则表达式验证器?
表达.

您将看到数字文本框.
add this javascript to you page.

Call this function by sending id you will get numeric text box

function EnterInteger(ID)
{
if(ID.value.length>0)
{
ID.value = ID.value.replace(/[^\d]+/g, '''');
}
}

or create regular expression validator with this \d+(\.\d{1,2})?
expression.

You will get numeric text box.


这篇关于如何验证TEXTBOX条目是仅数字形式还是特定数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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