开发者

From client, force whole page validation

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, displa开发者_如何学编程y the confirmation box.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜