从客户端强制整个页面验证

发布于 2024-09-02 01:00:06 字数 140 浏览 2 评论 0原文

我有一个 ASP 按钮,我已将其设置为 OnClientClick 属性以显示 javascript 确认消息。但是,我只希望在所有客户端验证通过后显示此消息。

我该怎么做?本质上,我认为我需要强制客户端进行页面级验证,然后只有在通过时才显示确认框。

I have an ASP button for which I have set the OnClientClick property to display a javascript confirm message. However, I only want this message to be displayed AFTER all of the client side validations have passed.

How can I do this? Essentially, I believe that I need to force Page level validation from the client and then, only if it passes, display the confirmation box.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久隐师 2024-09-09 01:00:07

如果您使用 ASP.NET 验证控件,请将这样的 OnClientClick 添加到您的提交按钮...

<asp:Button ID="blah" OnClientClick="if(Page_ClientValidate())return confirm('your message')" OnClick="your submit method" Text="submit" runat="server" />

...Page_ClientValidate() 将返回 true 如果页面已验证,那么您需要返回“确认”的结果命令提交表格。

这里有一些类似的内容: http://www.codeproject.com/KB/ aspnet/JavascriptValidation.aspx

If you're using the ASP.NET validation controls add an OnClientClick like this to your submit button...

<asp:Button ID="blah" OnClientClick="if(Page_ClientValidate())return confirm('your message')" OnClick="your submit method" Text="submit" runat="server" />

...Page_ClientValidate() will return true if the page is validated then you need to return the results of your "confirm" in order for the form to be submitted.

There's something along these lines available here: http://www.codeproject.com/KB/aspnet/JavascriptValidation.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文