Support forum for ASP.NET Zero (https://aspnetzero.com/).
User avatar
By eggersa
#5355 The default behavior of a form within a ASP.NET Zero template is to disable the submit button until the form is valid. Since I have a rather large form with multiple tabs I enable the button always as its difficult for the user to figure out why the button might be disabled. Instead, I handle the error event of the service proxy and if there are any validation errors I explicitly highlight the tabs with invalid form data.

Code: Select all            vm.save = function () {
                vm.saving = true;
                customerService.createOrUpdateCustomer(vm.customer).success(function () {
                    $uibModalInstance.close();
                }).error(function (error) {
                    if (error.validationErrors && error.validationErrors.length > 0) {
                        // hightlight tabs with invalid form controls...
                    }
                }).finally(function () {
                    vm.saving = false;
                });
            };


Unfortunately I would like to disable the default behavior of a service error in this case. By default, the templates behavior is to show a SweetAlert popup with the error message. How can I override this behavior for this special case?