Validation with AJAX

Jun 23, 2009 at 5:08 PM

Hello.  I've been playing with xVal for a few days now, and am very impressed.  However, I am running into issues when validating forms that use AJAX.  I had first used an ajax link that used the server side Ajax.ActionLink tag that was rendered as an anchor tag.  This did not cause the validation to fire, which is expected since its just an anchor tag with an onclick event.  (I am little confused about what event/s trigger validation, so that's one question.)

I than changed my form to use an ajax form with the server tag Ajax.BeginForm, and a submit button.  This caused the validation to trigger, but also allowed the ajax request to be sent.  I'm not sure how to fix this, or if this behaviour is not supported.  Are there examples of mvc ajax used with xVal? 


Thanks in advance.


Nov 5, 2009 at 2:41 PM

Hi Morten

xVal takes your server-defined validation rules and uses them to configure some client-side validation framework such as jQuery Validation. After that point, xVal is done and all that remains is the client-side validation framework.

Note ASP.NET MVC's Ajax.BeginForm (etc) helpers are wrappers around the ASP.NET AJAX libraries. I'm not certain that these are compatible with jQuery Validation, though I haven't directly checked because personally I haven't found use for Ajax.BeginForm and always use jQuery's simple Ajax helpers instead.