Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax.BeginForm beforeSubmit event

In MVC, is there a way to fire an onBeforeSubmit event when using Ajax.BeginForm? I'd like to validate some data on the client side and give proper feedback to the user.

like image 896
Carlos Blanco Avatar asked Oct 24 '11 14:10

Carlos Blanco


1 Answers

OnBegin is what you're looking for:

using (Ajax.BeginForm("Action", "Controller", 
new AjaxOptions() {
OnBegin = "alert('Replace with validation logic.')"
}))

UPDATE

Something like this:

   function onSubmitFeedbackBegin(context) {
        if (uploading > 0) {
            return false;
        }
    }
like image 110
digitalmarks Avatar answered Oct 13 '22 11:10

digitalmarks