简体   繁体   English

RequiredFieldValidator验证禁用的textBox

[英]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.

相关问题 如果TextBox不为空,则启用RequiredFieldValidator - Enable RequiredFieldValidator if TextBox is not empty 如何使用包含验证文本框值的RequiredFieldValidator控件的asp.net创建Web服务器控件 - how to create web server control using asp.net that contain RequiredFieldValidator control that validate textbox value 使用RequiredFieldValidator quickfix验证复选框列表 - validate a checbox list using RequiredFieldValidator quickfix asp:RequiredFieldValidator 不验证隐藏字段 - asp:RequiredFieldValidator does not validate hidden fields ASP .NET - RequiredFieldValidator在文本框之后创建空间 - ASP .NET - RequiredFieldValidator creates space after textbox 使用RequiredFieldValidator验证服务器控件中的文本框 - Validating textbox in Server Control using RequiredFieldValidator RequiredFieldValidator - RequiredFieldValidator 即使禁用了验证器,RequiredFieldValidator也会导致在服务器上进行验证(CausesValidation =“ false”) - RequiredFieldValidator causes validation on Server even if validator is disabled(CausesValidation=“false”) 即使禁用了验证器,Asp:RequiredFieldValidator也会导致在服务器上进行验证 - Asp:RequiredFieldValidator causes validation on Server even if validator is disabled 如何使用 jquery/javascript 将 asp:RequiredFieldValidator 分配给 asp:TextBox - How to assign asp:RequiredFieldValidator to asp:TextBox with jquery/javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM