Skip to content

Commit 6e0a4db

Browse files
authored
[Update] FormSubmit process updated
Hubspot integration and probably others require the "submit" button on the form to be clicked rather than the form.submit(); function to be triggered, for this case we added the attribute wt-formcheck-element="default-submit" so we can set a default submit button and push it to submit. Signed-off-by: Jorch C. <jacortez_94@hotmail.com>
1 parent 8318970 commit 6e0a4db

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Dist/Functional/FormCheck.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class FormCheck {
66
this.pattern = /^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\./0-9]*$/g;
77
this.errorClass = form.getAttribute("wt-formcheck-class");
88
this.submitMessage = form.getAttribute("wt-formcheck-message");
9+
this.defaultSubmitButton = form.querySelector('[wt-formcheck-element="default-submit"]');
910
this.requiredFields = form.querySelectorAll('[wt-formcheck-type="required"]');
1011
this.errorElements = form.querySelectorAll('[wt-formcheck-type="error"]');
1112
this.submitButton = form.querySelector('[wt-formcheck-type="submit"]');
@@ -80,8 +81,14 @@ class FormCheck {
8081
if (this.formErrors) {
8182
e.preventDefault();
8283
} else {
83-
this.submitButton.textContent = `${this.submitMessage}`;
84-
this.form.submit();
84+
if(this.defaultSubmitButton){
85+
this.submitButton.textContent = `${this.submitMessage}`;
86+
this.defaultSubmitButton.click();
87+
}
88+
else{
89+
this.submitButton.textContent = `${this.submitMessage}`;
90+
this.form.submit();
91+
}
8592
}
8693
}
8794

0 commit comments

Comments
 (0)