Skip to content

Form

A <form> that validates the rules of the fields inside it. Everything about rules, custom checks and server-side validation is in the Form validation guide.

We'll reply to this address

City

Services

---
import { Button, Form, TextInput } from 'bws-astro-ui';
import { email, required } from 'bws-astro-ui/rules';
---
<Form method="post" validateOn="blur">
<TextInput name="email" label="Email" rules={[required(), email()]} />
<Button type="submit">Send</Button>
</Form>
  • Fields with rules show their message in place of the hint and get aria-invalid.
  • A submit checks every field first; while anything is invalid it’s stopped, the first invalid field gets focus and your submit handlers on the form don’t run.
  • reset clears all messages.
  • The browser’s own validation bubbles are turned off once the script runs; without JavaScript the native attributes from the rules still validate.
Prop Type Default
validateOn blur · input · submit — when fields start validating blur

Any other attribute (method, action, id…) goes to the <form>. Slot: default — the fields.

Created byBanach Web SolutionsBanach Web Solutions