如何使用RegularExpressionvalidator验证文本框输入 [英] How to use RegularExpressionvalidator to validate textbox input
本文介绍了如何使用RegularExpressionvalidator验证文本框输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在文本框上创建了两个texbox,用户应该键入(From Month)(作为字符串)和第二个文本框(To Month),但我想验证文本框,以便用户只能在Januari,februari,march中书写等等?是否有任何表达方式?
I have created a two texboxes on textbox were the user should type (From Month)(as string) and second textbox (To Month) but i want to validate the textboxes so the user only can write in Januari,februari,march and so an? is there any expression to do that?
推荐答案
您可以在本网站上查看一些正则表达式工具:
Expresso - 构建和测试正则表达式的工具 [ ^ ]
正则表达式库生成器 [ ^ ]
正则表达式测试器 [ ^ ]
这可能是出于你的目的,但是如果我是你,我会使用正常的字符串操作或组合框。
You could take a look at some of the Regular Expression tools here on this site:
Expresso - A Tool for Building and Testing Regular Expressions[^]
Regular Expression Library Builder[^]
Regular Expression Tester[^]
This sould be engough for your purposes, however Id use normal String maipulation or a combobox if I were you.
你的意思是ASP .NET。
为什么你不给用户一个下拉菜单而不是一个文本框呢?
不过,你还可以用户正则表达式验证器 [ ^ ]。您的案例中的表达式是一个简单的枚举:^(1月| 2月| 3月| 依此类推)
You mean ASP.NET.
Why don''t you give the user a dropdown instead of a textbox, anyway?
Still, you can user regular expression validator[^]. The expression in your case is a simple enumeration:^(january|february|march|and so on)
使用自定义验证器 [ ^ ]并从代码中对数组进行验证
Of use custom validator[^] and validate from code against an array
这篇关于如何使用RegularExpressionvalidator验证文本框输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文