如何应用验证文本框仅接受并且仅接受“整数值"? [英] how can apply validation that text box accept only and only "interger values"

查看:64
本文介绍了如何应用验证文本框仅接受并且仅接受“整数值"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个文本框,我希望每当用户在运行时输入任何值时,该文本框仅接受整数值,请告诉我此问题的代码

i am using a text box and i want that whenever a user enter any value at runtime , the text box accept only integer value , please tell me the code for this problem

推荐答案

最简单的方法是对要在表单上填充属性的对象使用BindingSource,这样可以完成自动数据验证.

The easiest way is to use a BindingSource to an object with the properties you want to populate on the form, this way you get automatic data validation done.

public class formdata
{
   public int integerVal {get; set;}
   // other data
}


您可以通过两种方式实现此目标

1.使用javascript
2.使用ajax



2.使用ajax

you can achieve this in two ways

1. using javascript
2. using ajax



2.using ajax

<asp:TextBox ID="txtPincode" runat="server" class="txtfeild" MaxLength="6" />
                                                    <cc1:FilteredTextBoxExtender ID="txtPincode_FilteredTextBoxExtender" runat="server"

                                                        Enabled="True" TargetControlID="txtPincode" FilterMode="ValidChars" FilterType="Numbers">
                                                    </cc1:FilteredTextBoxExtender>


这篇关于如何应用验证文本框仅接受并且仅接受“整数值"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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