[英]RequiredFieldValidator to validate a disabled textBox
I've got a TextBox in which user can input a their desired username. 我有一个TextBox,用户可以在其中输入所需的用户名。 Underneath I've got a checkbox that once clicked it copies the user's email adress into the textfield and then disable it to prevent further changes. 在下面我有一个复选框,一旦点击它复制用户的电子邮件地址到文本字段,然后禁用它以防止进一步的更改。 This feature is implemented by using jQuery. 此功能是使用jQuery实现的。
The problem is that I've got a RequiredFieldValidator on that TextBox and it looks like it can't validate a disabled textfield, even if the value is set. 问题是我在TextBox上有一个RequiredFieldValidator,看起来它无法验证禁用的文本字段,即使该值已设置。
How can I solve this? 我怎么解决这个问题?
仅供将来参考:我通过设置属性“readonly”而不是“disabled”来修复此问题。
You could use a custom validator control like in this sample: 您可以使用自定义验证器控件,如下例所示:
http://asp.net-tutorials.com/validation/custom-validator/ http://asp.net-tutorials.com/validation/custom-validator/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.