views:

136

answers:

1

Possible Duplicate:
jquery validate & ajax.beginform

I'm trying to use the jQuery validate plugin to validate a form (Ajax.BeginForm). When I enter invalid data on the form the error messages are shown but the form will submit anyway. How do I stop MicrosoftMvcAjax from submiting an invalid form?

Thanks in advance

A: 

Ok, I got it!

All I need to do is pass the validate function to the OnBegin event in the AjaxOptions:

<% using (Ajax.BeginForm("SendMail", "Mail", new { @id = "MailForm", @class = "cmxform" }, new AjaxOptions { UpdateTargetId = "dialog", OnBegin = "validate" }, new { @id = "MailForm" }))
       { %>
Raphael