Skip to content

AK0060

Form submitted while invalid

What happened

You called submit() on a form, but one or more fields failed validation. AkashJS prevents submission of invalid forms by default.

How to fix

Check form.valid() before submitting, or fix the validation errors first. You can also display validation messages to guide the user.

Example

ts
// Bad — submitting without checking validity
const form = createForm({
  fields: {
    email: { required: true, validate: isEmail },
  },
});

function handleSubmit() {
  form.submit(); // form might be invalid!
}

// Good — check validity before submitting
function handleSubmit() {
  if (!form.valid()) {
    console.log("Fix errors:", form.errors());
    return;
  }
  form.submit();
}

Released under the MIT License.