@ohhwells/bridge 0.1.65-next.186 → 0.1.65-next.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6914,7 +6914,7 @@ function showSuccess(form, message) {
6914
6914
  note.innerHTML = text;
6915
6915
  form.replaceChildren(note);
6916
6916
  }
6917
- function showSubmitError(form) {
6917
+ function showSubmitError(form, message = "Something went wrong. Please try again.") {
6918
6918
  let note = form.querySelector("[data-ohw-form-error]");
6919
6919
  if (!note) {
6920
6920
  note = document.createElement("p");
@@ -6923,7 +6923,7 @@ function showSubmitError(form) {
6923
6923
  note.style.marginTop = "8px";
6924
6924
  form.appendChild(note);
6925
6925
  }
6926
- note.textContent = "Something went wrong. Please try again.";
6926
+ note.textContent = message;
6927
6927
  note.style.display = "";
6928
6928
  }
6929
6929
  function clearSubmitError(form) {
@@ -6988,6 +6988,11 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
6988
6988
  if (!formKey) return;
6989
6989
  e.preventDefault();
6990
6990
  clearSubmitError(form);
6991
+ const filled = collectFormFields(form);
6992
+ if (!Object.values(filled).some((value) => value.trim() !== "")) {
6993
+ showSubmitError(form, "Please fill in at least one field.");
6994
+ return;
6995
+ }
6991
6996
  const submitButton = form.querySelector(
6992
6997
  'button[type="submit"], input[type="submit"], button:not([type])'
6993
6998
  );
@@ -6999,7 +7004,7 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
6999
7004
  headers: { "Content-Type": "application/json" },
7000
7005
  body: JSON.stringify({
7001
7006
  formKey,
7002
- fields: collectFormFields(form),
7007
+ fields: filled,
7003
7008
  hasLongText: formHasLongText(form)
7004
7009
  })
7005
7010
  });