Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
haacked committed Jan 2, 2024
1 parent f77b4d6 commit 4d1e638
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
21 changes: 20 additions & 1 deletion dist/aspnet-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ var ValidationService = /** @class */ (function () {
* @param callback Receives true or false indicating validity after all validation is complete.
*/
this.validateForm = function (form, callback) {
if (!(form instanceof HTMLFormElement)) {
throw new Error('validateForm() can only be called on <form> elements');
}
var formUID = _this.getElementUID(form);
var formValidationEvent = _this.formEvents[formUID];
if (formValidationEvent) {
Expand Down Expand Up @@ -544,6 +547,9 @@ var ValidationService = /** @class */ (function () {
* @param submitEvent The `SubmitEvent`.
*/
this.handleValidated = function (form, success, submitEvent) {
if (!(form instanceof HTMLFormElement)) {
throw new Error('handleValidated() can only be called on <form> elements');
}
if (success) {
if (submitEvent) {
_this.submitValidForm(form, submitEvent);
Expand All @@ -563,6 +569,9 @@ var ValidationService = /** @class */ (function () {
* @param submitEvent The `SubmitEvent`.
*/
this.submitValidForm = function (form, submitEvent) {
if (!(form instanceof HTMLFormElement)) {
throw new Error('submitValidForm() can only be called on <form> elements');
}
var newEvent = new SubmitEvent('submit', submitEvent);
if (form.dispatchEvent(newEvent)) {
// Because the submitter is not propagated when calling
Expand All @@ -578,6 +587,10 @@ var ValidationService = /** @class */ (function () {
submitterInput.value = submitter.getAttribute('value');
form.appendChild(submitterInput);
}
var formAction = submitter.getAttribute('formaction');
if (formAction) {
form.action = formAction;
}
}
form.submit();
}
Expand All @@ -587,6 +600,9 @@ var ValidationService = /** @class */ (function () {
* @param form
*/
this.focusFirstInvalid = function (form) {
if (!(form instanceof HTMLFormElement)) {
throw new Error('focusFirstInvalid() can only be called on <form> elements');
}
var formUID = _this.getElementUID(form);
var formInputUIDs = _this.formInputs[formUID];
var invalidFormInputUIDs = formInputUIDs.filter(function (uid) { return _this.summary[uid]; });
Expand All @@ -607,6 +623,9 @@ var ValidationService = /** @class */ (function () {
*/
this.isValid = function (form, prevalidate, callback) {
if (prevalidate === void 0) { prevalidate = true; }
if (!(form instanceof HTMLFormElement)) {
throw new Error('isValid() can only be called on <form> elements');
}
if (prevalidate) {
_this.validateForm(form, callback);
}
Expand Down Expand Up @@ -660,7 +679,7 @@ var ValidationService = /** @class */ (function () {
*/
this.ValidationSummaryCssClassName = "validation-summary-errors";
/**
* Override CSS class name for valid validation summary. Default: 'field-validation-valid'
* Override CSS class name for valid validation summary. Default: 'validation-summary-valid'
*/
this.ValidationSummaryValidCssClassName = "validation-summary-valid";
this.logger = logger || nullLogger;
Expand Down
Loading

0 comments on commit 4d1e638

Please sign in to comment.