asp.net mvc - Microsoft MVC Validation.js: watch/create event to run custom function on real form submit -


i use microsoftmvcvalidation.js validate form (client side / no ajax).

when submit button clicked, form submitted. if there invalid form field error message shown instead of sending data server.

i want know how add custom function when form submitted server.

so example, can add simple js function disables submit button , shows 'loading' image, when submitted server. don't want disable button if validation message shows.

i cant use onsubmit event because does't assure form submitted server.

so how can it?

thanks

here's hack might use quite frankly consider jquery:

window.onload = function () {     document.getelementbyid('myform').onsubmit = function () {         // determine if there validation errors         var errors = sys.mvc.formcontext.getvalidationforform(this).validate('submit');         if (errors.length < 1) {             // disable button if there no errors             document.getelementbyid('btnsubmit').disabled = 'disabled';         }     }; }; 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -