@@ -18,7 +18,7 @@ angular.module("bootstrap.angular.validation").directive("form", ["$parse", "$ro
1818 restrict : "E" ,
1919 require : "form" ,
2020 priority : 1000 , // Setting a higher priority so that, this directive compiles first.
21- compile : function ( $formElement ) {
21+ compile : function ( $formElement , $formAttributes ) {
2222 // Disable HTML5 validation display
2323 $formElement . attr ( "novalidate" , "novalidate" ) ;
2424 bsValidationService . addDirective ( $formElement ) ;
@@ -41,6 +41,13 @@ angular.module("bootstrap.angular.validation").directive("form", ["$parse", "$ro
4141 bsValidationService . addToNgIncludedURLs ( src ) ;
4242 }
4343
44+ var ngSubmit = $formAttributes . ngSubmit ;
45+ /*
46+ * Removing ngSubmit attribute if any since ngSubmit by default doesn't respects the validation errors
47+ * on the input fields.
48+ */
49+ delete $formAttributes . ngSubmit ;
50+
4451 var preLinkFunction = function ( $scope , formElement , $attr , formController ) {
4552 // Expose a method to manually trigger the validation
4653 formController . $validate = function ( ) {
@@ -65,11 +72,8 @@ angular.module("bootstrap.angular.validation").directive("form", ["$parse", "$ro
6572 return false ;
6673 }
6774
68- // Do not show error once the form gets submitted
69- $scope . formSubmissionAttempted = false ;
70-
71- // Parse the handler of on-submit & execute it
72- var submitHandler = $parse ( $attr . onSubmit ) ;
75+ // Parse the handler of ng-submit & execute it
76+ var submitHandler = $parse ( ngSubmit ) ;
7377 $scope . $apply ( function ( ) {
7478 submitHandler ( $scope , { $event : e } ) ;
7579 $scope . formSubmissionAttempted = false ;
0 commit comments