Skip to content

Commit 1c8d8af

Browse files
authored
Merge pull request #1 from haacked/submit-propagation
Only handle form submit event when form not valid
2 parents 193b2f7 + 06401d7 commit 1c8d8af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aspnet-client-validation",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Enables ASP.NET MVC client-side validation, without jQuery!",
55
"main": "dist/aspnet-validation.js",
66
"style": "dist/aspnet-validation.css",

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,19 +627,19 @@ export class ValidationService {
627627
return;
628628
}
629629

630-
let isProgrammaticValidate = !e;
631-
if (!isProgrammaticValidate) {
632-
e.preventDefault();
633-
}
634630
validate.then(success => {
631+
let isProgrammaticValidate = !e;
635632
if (success) {
636633
if (isProgrammaticValidate) {
637634
callback(true);
638635
return;
639636
}
640-
form.submit();
641637
return;
642638
}
639+
else {
640+
e.preventDefault();
641+
e.stopImmediatePropagation();
642+
}
643643
if (isProgrammaticValidate) {
644644
callback(false);
645645
}

0 commit comments

Comments
 (0)