ASP.NET TextBox的内容验证! [英] ASP.NET TextBox's content validation !

查看:115
本文介绍了ASP.NET TextBox的内容验证!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个网页表单,其中包含名为txtEmpNo的文本框。在那个文本框中我只想输入数字。另一方面,我想在输入A-Z时将内容限制为数字,文本框不应该允许这样做!



我使用C#.Net和ASP。净



如何解决这个问题?我已经在ASP.Net中看到了CustomValidation控件,但我不知道如何验证ASP.Net中文本框的内容以验证使用它!



如果你可以帮我做那个!



谢谢

Chiranthaka

解决方案

< blockquote>尝试使用蒙面编辑控件 [ ^ ]。


< blockquote>使用RegularExpression验证器并使用它:^ [0-9] {1,7}


作为正则表达式。然后,您可以将错误消息更改为您想要的任何内容。


I have created a a web form that has text box called ''txtEmpNo''. At that text box I only want to enter numbers. In other hand I want to restrict the content to numbers when enter A - Z that text box should not allow to do that!

I use C#.Net with ASP.Net

How am going to solve that? I already seen the CustomValidation control in ASP.Net but I do not know how to validate the content of a text box in ASP.Net to validate using it!

If you can please help me to do that!

Thanks
Chiranthaka

解决方案

Try using the Masked Edit Control[^] from the ASP.NET AJAX Control Toolkit.


Use a RegularExpression validator and use this: ^[0-9]{1,7}


as your regular expression. Then you can change the error message to whatever you want.


这篇关于ASP.NET TextBox的内容验证!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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