显示“通过”验证 asp.net (req. field)validator 后的图像或文本
我有以下 asp.net 代码:
<asp:TextBox CssClass="mf" runat="server" ID="mail1" Width="270" />
<asp:RequiredFieldValidator ID="rfv1"
runat="server"
ControlToValidate="mail1"
Display="Dynamic" />
现在,如果验证通过(无回发),我想显示图像(或文本)
jQuery 解决方案对我来说也很好,但如果 javascript 那就不太安全了已禁用。
I have the following asp.net code:
<asp:TextBox CssClass="mf" runat="server" ID="mail1" Width="270" />
<asp:RequiredFieldValidator ID="rfv1"
runat="server"
ControlToValidate="mail1"
Display="Dynamic" />
Now I want to show an image (or text) if the validation passes on the fly (no postback)
A jQuery solution is also fine by me, but that wouldn't be so safe if javascript is disabled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需依赖外部框架,您就可以利用 ASP.Net 客户端验证框架来处理扩展/高级功能。通过这种方式,您可以使用框架,增强它而不是替换它。
只需一点点 JavaScript 就可以实现您想要的行为。
请注意,我使用的是 ASP.Net 4 的 ClientIDMode="Static" 功能,如果您不使用 .Net 4,那么您将需要使用标准
<%= rfv1.ClientID %> 服务器端包含以获取脚本中的客户端 ID。
Without relying on an external framework you can tap into the ASP.Net Client Side Validation framework to handle extended/advanced functionality. In this way you are working with the framework, augmenting it instead of replacing it.
A tiny bit of JavaScript is all that is needed to enable the behavior you want.
Notice here that I am using a feature of ASP.Net 4 with ClientIDMode="Static" if you are not using .Net 4 then you will need to use the standard
<%= rfv1.ClientID %>
server side include to get at the client id inside your script.