需要实地验证号码验证 [英] Number validation in required field validator
问题描述
是否有可能把号码验证所需的字段校验器在asp.net文本框中?
Is it possible to put Number validation in required field validator in asp.net text box?
推荐答案
您应该使用CompareValidator,例如:
<asp:TextBox ID="txt" runat="server />
<asp:CompareValidator ID="cv" runat="server" ControlToValidate="txt" Type="Integer"
Operator="DataTypeCheck" ErrorMessage="Value must be an integer!" />
这是最自然的选择,如果你想要一个简单的数据类型检查。否则,如果您想验证一个范围内使用RangeValidator建议。如果你需要一个特定的模式使用RegularEx$p$pssionValidator.
This is the most natural choice if you want a simple data type check. Otherwise if you want to verify a range use the RangeValidator suggestions. If you need a certain pattern use the RegularExpressionValidator.
请注意,您要添加<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.requiredfieldvalidator.aspx\">RequiredFieldValidator还有因为一些验证器将允许空白项。
Note that you'll want to add a RequiredFieldValidator as well since some validators will allow blank entries.
这篇关于需要实地验证号码验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!