Is it possible to put Number validation in required field validator in asp.net text box?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- Angular Material Stepper causes mat-formfield to v
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
You should use the CompareValidator, for example:
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.
Note that you'll want to add a RequiredFieldValidator as well since some validators will allow blank entries.
A RequiredFieldValidator only checks if the field is filled in. It doesn't care what with.
You will need an extra CompareValidator with it's Operator set to DataTypeCheck and it's Type set to Integer. Note you need both: the CompareValidator will ignore an empty input.
Yes, like this:
No, a RequiredFieldValidator can only verify that the field contains something.
If you want to verify that the field only contains digits, you can use a RegularExpressionValidator with the pattern
"\d+"
.Another possibility is using the RegexpValidator and adding a regular expression that makes sure there's 1 or more digits in it, something like:
Maybe you can use a RangeValidator attached to that textbox, setting Type to Integer or wathever.
RangeValidator class on MSDN