如何隐藏(客户端)的div是客户端验证失败? [英] How do I hide a div (on the client) is client-side validation fails?
问题描述
我在做一个asp.net页面asp.net验证控件。如果验证失败,我想说明一个div(客户端)。我在哪里做呢?我不能找到一种方法来访问客户端上的OnValidate事件。我能做到这一点的服务器上,但我宁愿做在客户端上。
I'm making an asp.net page with asp.net validation controls. If validation fails, I want to show a div (on the client). Where do I do this? I can't find a way to access the OnValidate event on the client. I can do this on the server, but I'd rather do it on the client.
推荐答案
使用一个ASP.NET的自定义验证。
Use an ASP.NET custom validator.
如果由于某种原因,你不能/不想这样做,使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registeronsubmitstatement.aspx]\"相对=nofollow> ClientScriptManager.RegisterOnSubmitStatement 方法,并确保在客户端脚本返回false,如果你在任何验证失败。
If for some reason you can't/don't want to do that, use a ClientScriptManager.RegisterOnSubmitStatement method, and ensure to return false in the client-side script if whatever you're validating fails.
这篇关于如何隐藏(客户端)的div是客户端验证失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!